由买买提看人间百态

topics

全部话题 - 话题: col3
1 2 下页 末页 (共2页)
l******9
发帖数: 579
1
I am sorting two tables on SQL.
The two tables have the same column names and types and rows numbers.
I used order by to do sorting but the two tables are different in order.
Example,
col1 INT
col2 INT
col3 INT
col4 DOUBLE PRECISION
SELECT *
FROM table1 AS t1
ORDER BY t1.col1 , t1.col2, t1.col3, t1.col4 ASC
SELECT *
FROM table2 AS t2
ORDER BY t2.col1 , t2.col2, t2.col3, t2.col4 ASC
Table1 is :
col1 col2 col3 col4
80 790 3498 18654.064361
81 589 3182 2138518.05404
80 ... 阅读全帖
l******9
发帖数: 579
2
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: sort two same tables SQL but different results
发信站: BBS 未名空间站 (Fri May 9 09:57:41 2014, 美东)
I am sorting two tables on SQL.
The two tables have the same column names and types and rows numbers.
I used order by to do sorting but the two tables are different in order.
Example,
SELECT *
FROM table1 AS t1
ORDER BY t1.col1 , t1.col2, t1.col3, t1.col4 ASC
SELECT *
FROM table2 AS t2
ORDER BY t2.col1 , t2.col2, t2.col3, t2.col4 ASC
T... 阅读全帖
w*r
发帖数: 2421
3
来自主题: Database版 - Teradata 的大拿呢
来讨论一下join index的用法,说说你们的经历,我先砸一块砖,V2R6.1的optimizer
有问题
我有一个commonly used join(为了简便,很多syntax 的细节错误就不管了),
Table A Inner Join B on
a.col1=b.col1 and a.col2=b.col2 and a.col3=b.col3
and a.start_date <= b.start_date and a.end_date >= b.end_date
Table A 和 B分别对这些join的col都有hash index.
我建立了一个A $ B 的JI
create A_B_JI as
select a.col1, b.col1, a.col2, b.col2 , a.col3, b.col3 a.started_date
a.rowid, b.rowid
from a join b
on a.col1=b.col1 and a.col2=b.col2 and a.col3=b.col3
and a.start_date <= b.start_date an
i*****w
发帖数: 75
4
来自主题: Database版 - 请教一个SQL的问题
Method 1: Row_Number, Partition by
Method 2: Assume there are no duplicated records for each group so Col1 and
Col3 are unique:
Declare @tbl Table (col1 varchar(10), col2 varchar(10), col3 int)
INSERT INTO @tbl (col1, col2, col3)
SELECT 'A', 'S', 4 UNION ALL
SELECT 'A', 'T', 12 UNION ALL
SELECT 'A', 'U', 14 UNION ALL
SELECT 'A', 'V', 6 UNION ALL
SELECT 'A', 'W', 9 UNION ALL
SELECT 'A', 'X', 17 UNION ALL
SELECT 'A', 'Y', 23 UNION ALL
SELECT 'A', ... 阅读全帖
s*******n
发帖数: 4402
5
来自主题: Database版 - 请教一个SQL的问题
楼上几位都是高手,给出的解比较复杂,我给一个简单的:
先建一个#table, 原来的表是tb
create table #table (col1 char(1), col2 char(1), col3 int)
insert into #table(col1) (select distinct col1 from tb)
update #table set col3=c.min_col3
from #table as t
join (select min_col3=min(col3), col1 from tb
) as c on t.col1=c.col3
update #table set col2=t.col2
from #table as t join tb as b on t.col1=b.col1 and t.col3=b.col3
不管你原来数据有没有重复的,你就是要最小的那一行,这个可以达到要求。
l******9
发帖数: 579
6
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: sort two same tables SQL but different results
发信站: BBS 未名空间站 (Fri May 9 09:57:41 2014, 美东)
I am sorting two tables on SQL.
The two tables have the same column names and types and rows numbers.
I used order by to do sorting but the two tables are different in order.
Example,
SELECT *
FROM table1 AS t1
ORDER BY t1.col1 , t1.col2, t1.col3, t1.col4 ASC
SELECT *
FROM table2 AS t2
ORDER BY t2.col1 , t2.col2, t2.col3, t2.col4 ASC
T... 阅读全帖
l******9
发帖数: 579
7
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: sort two same tables SQL but different results
发信站: BBS 未名空间站 (Fri May 9 09:57:41 2014, 美东)
I am sorting two tables on SQL.
The two tables have the same column names and types and rows numbers.
I used order by to do sorting but the two tables are different in order.
Example,
SELECT *
FROM table1 AS t1
ORDER BY t1.col1 , t1.col2, t1.col3, t1.col4 ASC
SELECT *
FROM table2 AS t2
ORDER BY t2.col1 , t2.col2, t2.col3, t2.col4 ASC
T... 阅读全帖
l******y
发帖数: 60
8
来自主题: Database版 - 请教一个SQL的问题
问个问题
我有如下table:
col1 col2 col3
A S 4
A T 12
A U 14
A V 6
A W 9
A X 17
A Y 23
A Z 346
B S 45
B T 34
B U 34
B V 56
B W 67
B X 342
B Y 23
B Z 1
C S 34
C T 78
C U 3
C V 8
C W 34
C X 6
C Y 7
C Z 100
对于col1 中的每个值,要找出col3值最小的一列。即如下结果:
col1 col2 col3
A S 4
B Z 1
C U 3
Table很大,每一个distinct col1 都有80万个col2与之对应,即: select count(*)
wher... 阅读全帖
n***l
发帖数: 27
9
来自主题: Database版 - Urgent SQL problem!
SELECT a.col1, a.col2, a.col3 FROM A a
I'd like to case when a.col3 is not null then
INNER JOIN B b ON a.col3 = b.col3
case when a.col3 is null then
do not inner join B.
How to make it? Thanks million!
n***l
发帖数: 27
10
来自主题: Database版 - Urgent SQL problem!
SELECT a.col1, a.col2, a.col3 FROM A a
I'd like to case when a.col3 is not null then
INNER JOIN B b ON a.col3 = b.col3
case when a.col3 is null then
do not inner join B.
How to make it? Thanks million!
B*****g
发帖数: 34098
11
来自主题: Database版 - 问个简单的sql语句
Oracle will fire the trigger, usually need to add WHEN clause to the trigger
.
I do know much about mysql.
how about
update xxxtable set col2 = col2||''
update xxxtable set col2 = col2, col3=col3
update xxxtable set col2 = col2, col3=col2
update xxxtable set col2 = CASE WHEN 1=1 THEN col2 ELSE col3 END
i*****w
发帖数: 75
12
建议一种方法:
1) UNPIVOT TableA, You will get:
ID1, COL1, CONTENT1
ID2, COL2, CONTENT2
ID3, COL3, CONTENT3
2) Join TableA and TableB by LIKE.
EXAMPLE:
-- Prepare Source Table
DECLARE @tblA Table (ID int identity, col1 varchar(100), col2 varchar(100),
col3 varchar(100))
INSERT INTO @tblA (col1, col2, col3)
SELECT 'this is a test', 'I am not sure', 'Give it a try.'
UNION ALL
SELECT 'who cares', 'No one knows', 'Why not'
UNION ALL
SELECT 'it is impossible', 'please let me know', 'be honest'
-- ... 阅读全帖
a****k
发帖数: 117
13
来自主题: Database版 - Urgent SQL problem!
SELECT a.col1, a.col2, a.col3 FROM A a INNER JOIN B b ON a.col3 = b.col3
WHERE a.col3 IS NOT NULL
b****1
发帖数: 242
14
来自主题: Programming版 - 急:问一个SQL的题目
SELECT aaa.year,
MAX(CASE WHEN aaa.col2= 'WRA0020' THEN aaa.col3 ELSE NULL END),
MAX(CASE WHEN aaa.col2= 'OO0036' THEN aaa.col3 ELSE NULL END),
MAX(CASE WHEN aaa.col2= 'WRA0019' THEN aaa.col3 ELSE NULL END),
MAX(CASE WHEN aaa.col2= 'OO0033' THEN aaa.col3 ELSE NULL END),
FROM
(
SELECT * FROM a
WHERE col1 = ('DE00000009') AND (col2 = 'WRA0020' or col2 = 'OO0036' or col2
= 'WRA0019' or col2 = 'OO0033')
) aaa
GROUP BY aaa.year
c*********e
发帖数: 16335
15
来自主题: Programming版 - 请教思路 数据同步有关
(select col1,col2,col3 from table1
except
select col1,col2,col3 from table2)
union
(select col1,col2,col3 from table2
except
select col1,col2,col3 from table1)
t*********i
发帖数: 217
16
来自主题: Database版 - Oracle SQL Tunning Problem!
try this one?
select a.a_col0 from tab_A a, (select to_char(B.B_col1) as col3 from tab_B B
where B.B_col2 in (to_number(:variable_0, '9999999'))) c
where a.a_col4=c.col3
and a.a_col1='P'
and a.col2 = 'U'
and a.col3 between to_date (....)
a*********u
发帖数: 1463
17
来自主题: Database版 - 问个sql/ ssis的问题 谢谢!
有两个sql server table
table1 (col1, col2, col3 ... col9)
table2 (cola, colb, colc)
目的是弄一个 excel table3
包含col1, col2, col3, col5, col6, colc
colc的值是当tbl1.col1=tbl2.cola and tbl1.col2 = tbl2.colb
我现在的想法是
select col1,col2,col3, col5, col6, 0 as colc from tbl1 into temp_tbl1
update temp_tbl1
set temp_tbl1.colc = tbl2.colc
from temp_tbl1
inner join tbl2
on (temp_tbl1.col1 = tbl2.cola and temp_tbl1.col2 = tbl2.colb)
然后再用ssis 把数据弄到excel里
请问还有什么简单易操作的方法吗
谢谢
e*********y
发帖数: 29
18
来自主题: Database版 - 高手请进
table A
Id,col1,col2,col3
1 a b c
2 c e f
3 a b c
4 a b c
table B
col1,col2,col3,Id
aa bb cc 1
cc bb dd 1
ee ff gg 1
ff aa ee 2
aa bb cc 2
bb ee ff 4
cc bb dd 4
ee ff gg 3
table c:
col1,col1,col2,col3, count
1 aa bb cc 2
2 cc bb dd 2
3 ee ff gg 2
4 ff aa ee 1
5 bb ee ff 1
现在有table A, table B, 和 table c
有没有办法不用每次run Inquery,而直接得到table c 的结果.
就是说table C的结... 阅读全帖
s***s
发帖数: 1301
19
我有两个个表Table A 有3个column Col1, Col2, Col3,和Keyword Table B it has
keyword1, keyword2, keyword3.....
我想查Table A 中有哪些record, 其任何一个column (Col1, or Col2, or Col3) 有
任何一个Table B 中keyword 。
我想到的方法是:
利用cursor 来获取一个一个keyword, 然后传到@p1 下面的dynamic query来查取
select *
from A
where Col1 like '%@p1%' or Col2 like '%@p1%' or Col3 like '%@p1%'
问题是我的keyword table可能有上千个,这种方法就比较低效。
请问有什么比较好的方法来实现呢?
谢谢!
s**********o
发帖数: 14359
20
来自主题: Database版 - 请教一个sql问题
你的TABLE1的各个COLUMN NAME是什么呢,我觉得TABLE1本身就有问题
TABLE 1,如果是这样一个TABLE,本身就没有意义
ID COL1 COL2 COL3
1 小甲 老乙 大丙
2 小A 老B 大C
3 张三 李四 王二麻子
显然,虽然叫COL1, COL2. COL3,但肯定是有些联系,其实是这样的
COL1=学生
COL2=老师
COL3=家长
其实TABLE1应该是这样
ID 学生 老师 家长
1 小甲 老乙 大丙
2 小A 老B 大C
3 张三 李四 王二麻子
如果TABLE1建好的话,TABLE2和TABLE3都没什么意义,如果你是CLEANUP
直接SELECT COL1 AS ID1, COL2 AS ID2, COL3AS ID3 FROM TABLE1
因为是DDL,你的COLUMN数肯定是一定的,不可能是N个,只能一一列举
不过合并后的TABLE3还是没什么意义,因为ID1 ID2本身... 阅读全帖
o******6
发帖数: 538
21
来自主题: Statistics版 - [合集] 请教:SAS help
☆─────────────────────────────────────☆
cyear (cyear) 于 (Wed May 14 23:40:09 2008) 提到:
有个文件:
A 4
A 5
B 1
B 2
B 3
怎么能得到:
A 9
B 6
谢谢!!
☆─────────────────────────────────────☆
cyear (cyear) 于 (Wed May 14 23:59:31 2008) 提到:
哪位帮帮忙!1
☆─────────────────────────────────────☆
GunS (火枪) 于 (Thu May 15 08:24:25 2008) 提到:
proc sort data=a;
by col1;
run;
data b;
set a;
by col1;
if first.col1 then col3=0;
col3+col2;
if last.col1;
drop col2;
rename col3=col2;
run;

有个文件:
A 4
A 5
B
l******9
发帖数: 579
22
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: SQL copy a table into a new table and add a new column
发信站: BBS 未名空间站 (Fri May 23 12:05:22 2014, 美东)
need to copy a table into a new table on SQL server 2008. Also, add a new
column into the new table.
The values of the new column depends on the compare result between the new
table and another table.
Example,
Table1:
col1 col2 col3
abc 346 6546
hth 549 974
Table1_new:
col1 col2 col3 c... 阅读全帖
B*****g
发帖数: 34098
23
来自主题: Database版 - sql query help
SELECT col1, col2, col3, COUNT(1)
FROM tab1
GROUP BY ROLLUP(col1, (col2,col3))
B*****g
发帖数: 34098
24
来自主题: Database版 - 菜鸟问题,急
CREATE TABLE NewTable AS
SELECT *
FROM ( SELECT COL1,COL2 FROM Table1
UNION ALL
SELECT COL3,COL4 FROM Table2)
or
INSERT INTO NewTable
SELECT *
INTO NewTable
FROM ( SELECT COL1,COL2 FROM Table1
UNION ALL
SELECT COL3,COL4 FROM Table2)
M***7
发帖数: 2420
25
来自主题: Database版 - 菜鸟问题,急
guys, thanks a lot .
Finally I used the following query
=====================
INSERT INTO NewTalbe
SELECT col1, col2 FROM TABLE1
UNION ALL
SELECT col3 col4 FROM TABLE2
======================
It woks.
If I use
=================
CREATE TABLE newtable AS
SELECT *
FROM (SELECT col1, col2 FROM TABLE1
UNION ALL
SELECT col3 col4 FROM TABLE2)
===================
It still did not work.
Could anyone explain it a little bit detail for me? I am really a rookie in
SQL.
Thanks.
d**e
发帖数: 6098
26
In oracle, say select max,
col1 col2 col3
--------------------
a b 1
a b 2
c d 4
c d
-------------------
group by col1, col2, i want something like a/b will return 2, c/d return
null, since c/d has a null value.
"select col1, col2, max(col3) from table group by col1, col2" doesn't work.
Is ia any way to make the max function return null if there is a null value
in the column?
Thanks!
T****U
发帖数: 3344
27
来自主题: Database版 - 请教几个面试题
My answer to Q3
select * from
((select col1, col2, col3, col4, col5 from sevencol)
minus fivecol)
Union
(fivecol minus
(select col1, col2, col3, col4, col5 from sevencol))

query
A*******n
发帖数: 625
28
来自主题: Database版 - 请教一个SQL的问题
try this:
select *
from
(select col1,col2,col3, RANK() over (partition by col1 order by col3) as
rank
from tab1 ) t
where t.rank=1
l******9
发帖数: 579
29
need to copy a table into a new table on SQL server 2008. Also, add a new
column into the new table.
The values of the new column depends on the compare result between the new
table and another table.
Example,
Table1:
col1 col2 col3
abc 346 6546
hth 549 974
Table1_new:
col1 col2 col3 col4
abc 346 6546 1
hth 549 974 0
Table2:
col1
abc
sfsdf
If Table2's col1 appear in Table1 col1, mark col4 as 1 in Table1_new, el... 阅读全帖
c*****d
发帖数: 6045
30
来自主题: Database版 - 请问sql 有条件性的select columns
首先,这个表这么设计不好
不过估计你也不能改表的设计
类似是同一时间N个传感器传回过来的数据
其次,cursor不是干这个用的
cursor是move from one row to the other
这个就是一个简单的nested if
if ( col2 is not null )
return col2
elsif ( col3 is not null )
return col3
elsif ( col4 is not null )
return col4
...
x******m
发帖数: 736
31
来自主题: Database版 - 请教一个sql问题
table1
id col1 col2 col3...
table2
col_id col_name
1 col1
2 col2
3 col3
现在想用sql生成table3,
id col_name col_value
其中id,col_vaule来自于table1,col_name来自于table2.
多谢。
c*********e
发帖数: 16335
32
来自主题: Programming版 - 请教思路 数据同步有关
表a 加一个column: lasttimechanged
写个stored procedure,里面写2个query:
insert * into table1 + year() + month() + day() + hour() + min()
select * from A
where lasttimechanged >= (min()-10min)
and lasttimechanged <= getdate();
--有时候,即使是update,也可能新数据和老数据完全相同,所以也要加上下面这个sql:
select col1,col2,col3 (不包括column lasttimechanged) from table1 + year() +
month() + day() + hour() + min()
except
select col1,col2,col3 (不包括column lasttimechanged) from table1 + year() +
month() + day() + hour() + (min()-10min)
每10分钟运行一次这个s... 阅读全帖
l******9
发帖数: 579
33
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: SQL copy a table into a new table and add a new column
发信站: BBS 未名空间站 (Fri May 23 12:05:22 2014, 美东)
need to copy a table into a new table on SQL server 2008. Also, add a new
column into the new table.
The values of the new column depends on the compare result between the new
table and another table.
Example,
Table1:
col1 col2 col3
abc 346 6546
hth 549 974
Table1_new:
col1 col2 col3 c... 阅读全帖
o******6
发帖数: 538
34
☆─────────────────────────────────────☆
davfox121 (davfox) 于 (Sat Mar 7 08:57:42 2009) 提到:
假设有col1, col2, col3-----coln, 这儿n 是一个变量,不是常数, 我想把这几个
colume合成一个colume,请问如何用macro做?(不能用col1||col2||col3---,因为不
知道n是多少)
我想用循环,%do i=1 %to %n %by 1; %let finalcol=&finalcol||col&i; %end
但是好像不认col&i
是不是用proc sql 可以, 象
select * into:ary1-:ary&n from dataset where obs=&i;
%let finalcol='';
%do i=1 %to %n %by 1;
%let finalcol=finalcol||ary&i;
%end;
有谁还有好的方法吗?
还有,要是几个colume的type 不一样的话(例如如果有numeric), 该如何处理呢?
l******9
发帖数: 579
35
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: SQL copy a table into a new table and add a new column
发信站: BBS 未名空间站 (Fri May 23 12:05:22 2014, 美东)
need to copy a table into a new table on SQL server 2008. Also, add a new
column into the new table.
The values of the new column depends on the compare result between the new
table and another table.
Example,
Table1:
col1 col2 col3
abc 346 6546
hth 549 974
Table1_new:
col1 col2 col3 c... 阅读全帖
e****e
发帖数: 2010
36
方法比较傻瓜,需要把Code编辑好,安装浏览器Extension。 职业高中,技校的,文科
女生可以试试,大牛和名校毕业的就算了。觉得有用就给些包子,饿S了。
1) Download and Install iMacros IE extension
http://download.cnet.com/iMacros-for-Internet-Explorer/3000-125
10586882.html
2) Create your code CVS txt file, PlumTarget.txt, Looks like:
Email,CardN,AccessN,RedeemN
xxx@xxx,xxxx,xxxx,xxxxxx
xxx@xxx,xxxx,xxxx,xxxxxx
…...................
Note: 四列文件,只有逗号,没有任何空格。可以用Excel, 存为cvs text file.
3) Edit and Play iMacros File
Edit #Current.iim file as following, save as any file n... 阅读全帖
d**********o
发帖数: 1321
37
来自主题: WebRadio版 - 潜水员冒泡兼征版友意见
RTOS作业:2514
The purpose of this assignment is to give you more experience using the AVR
ports, and to add some I/O devices that might become useful later for our
RTOS.
You are to use one of the provided keypads to implement a “digital lock.”
Your program should allow the user to enter a four digit code from the
keypad, and if the code that is input matches the one included in your
program, the “lock” should open. In this case, the lock opening will be
represented by the lighting of an LED.
As th... 阅读全帖
d**********o
发帖数: 1321
38
来自主题: WebRadio版 - 潜水员冒泡兼征版友意见
RTOS作业:2514
The purpose of this assignment is to give you more experience using the AVR
ports, and to add some I/O devices that might become useful later for our
RTOS.
You are to use one of the provided keypads to implement a “digital lock.”
Your program should allow the user to enter a four digit code from the
keypad, and if the code that is input matches the one included in your
program, the “lock” should open. In this case, the lock opening will be
represented by the lighting of an LED.
As th... 阅读全帖
w**********1
发帖数: 2588
39
来自主题: TrustInJesus版 - 同志並不難找
【Mat24:12】
只因不法的事增多,许多人的爱心,才渐渐冷淡了。
【Eph4:22】
就要脱去你们从前行为上的旧人。这旧人是因私欲的迷惑,渐渐变坏的。
这几段经文中,一个共同点是,都有"渐渐"一词。
人的堕落,和 人的成圣, 都不是一蹴而就的。
这个过程的特点是,今天和昨天,区别很小,每一天的区别都
很小,所以,人感觉不到自己的堕落,有足够的时间把每一次
细微的变化合理化, 于是,对善的定义经过一次一次的微调。
所以,没有几个人,能够很容易的意识到自己的堕落,
而总是倾向于认为自己对善的标准是始终如一的。
而且,一代一代人下来,很多人都觉得自己出生的环境中周遭的人,
特别是至亲的人的行为,就是完美的对善的标准的诠释,
所以很多小孩在道德标准上都是继承了自己的父母,
并以此为起点,在跟周围的环境互动中,自身的道德标准开始变化,
开始渐渐的堕落。人类的堕落就是这么继承下来的。
所以,很多堕落了的人,并没有罪恶感,因为他们觉得自己跟起初的自己,
改变的并不大,也许只是坏了一点点而已。 只不过, 70后,80后,90后,
道德标准就是这样一代不如一代的。但是,70后跟90后的比较,已经能... 阅读全帖
c*****d
发帖数: 6045
40
来自主题: Database版 - Remove duplicate from oracle table
4肯定是最差
3应该比1快,如果col2, col3上有index估计就差不多了
在toad里执行一下,贴个执行计划看看
别直接贴在bbs上,上传附件比较清晰一些
M***7
发帖数: 2420
41
来自主题: Database版 - 菜鸟问题,急
请问下面这个QUERY为什么不WORK
SELECT *
INTO NewTable
FROM ( SELECT COL1,COL2 FROM Table1
UNION ALL
SELECT COL3,COL4 FROM Table2)
括号里的QUERY单独可以work。这里我如果想加order by 的话可以吗?
谢谢
b*****e
发帖数: 364
42
来自主题: Database版 - 菜鸟问题,急
Try this one. Just add a alias name.
SELECT *
INTO NewTable
FROM ( SELECT COL1,COL2 FROM Table1
UNION ALL
SELECT COL3,COL4 FROM Table2) a
M***7
发帖数: 2420
43
来自主题: Database版 - A rookie's query question
Hi all. I am a newbie with SQL. Here is my question:
The table is like
col1 col2 col3
a1 1 c
a1 2 a
...
a1 100 t
a2 1 d
a2 2 c
...
a2 100 g
a3 1 h
...
a3 100 d
now I am trying to make a function. The parameters are 2 ints of col2(such
as 2,81). I want to return a table containing the composition of that two
input parameters which is like
for parameter (2,81)
dt 10%
ac 40%
tt 50%
could anyone help me out?
M***7
发帖数: 2420
44
来自主题: Database版 - A rookie's query question
Sorry for the confusion.
this query is like suppose I have a sequence a1 with "agdgteddgg", then I
put it into the table as below:
col1 col2 col3
a1 1 a
a1 2 g
a1 3 d
...
a1 10 g
then I get 9 other different sequences (a2-a10) and put them into the table
in the same format.
Then I want to check for all sequences, what is the combination of
composition at position 2 and position 8.
so it could be
h******l
发帖数: 422
45
来自主题: Database版 - 问个sql/ ssis的问题 谢谢!
你的意思是:
假设 tbl1:
col1 col2 col3 col4 col5 col6
m*****i
发帖数: 2325
46
来自主题: Database版 - 一个oracle performance 的问题。
oracle 9i。
我有一个大table 叫 TA 吧, 7,8 个million record 吧。
table 有primary key。 由好几个column 组成。就叫 (col1,col2,col3,col4,
col5,col6) 吧。
当我运行如下query 时,非常慢,要十几分钟。
1) select count(*) from TA a where a.col1=601
但当我运行下面的query 是 却非常快,十几秒就行了。
2) select count(*) from TA a where a.col1=601 and a.col2 like 'ABC%'
为什么呢? 有什么办法可以让 1) 也运行的快点吗?
B*****g
发帖数: 34098
47
CASE SUM(CASE WHEN col3 IS NULL THEN 1 ELSE 0 END) WHEN 0 THEN COUNT(*) ELSE
NULL END

.
value
c*****d
发帖数: 6045
48
来自主题: Database版 - 这个sql语句怎么写
b和c表中column不一样多,当然在select后面选取的column是一样多的
类似
select a.col1, a.col2, b.col3
union
select a.col1, a.col2, c.col5
c*****d
发帖数: 6045
49
来自主题: Database版 - 这个sql语句怎么写
select a.col1, a.col2, b.col3
from a,b
where a.col1 = b.col1
and a.col2 = a1
union all
select a.col1, a.col2, c.col5
from a,c
where a.col1 = c.col1
and a.col2 <> a1
k***n
发帖数: 997
50
来自主题: Database版 - sql 题目求助
1, 有一个客户_good_.dbo.transactions, 其中包括
acct: unique customer identifier, purchdate: date when purchase occurred,
purchasemt: purchase amount
要求:select all acct with first purchase happened in 2012 and his total
purchase amount > 250$
2, 还是这个table, find the proportion of customers that made more than one
purchases in 2012 fiscal year. return a table where col1 is number of
customers that made more than one purchases in 2012 fiscal year, col2 total
number of customers ever purchased from us, col3 s... 阅读全帖
1 2 下页 末页 (共2页)