嗨,我在oracle sql dab中具有以下数据:
AS_OF_DATE TICKER SCORE_1 SCORE_2
'20130301' 'BCO' 0.9 0.3
'20130409' 'BCO' 0.8 0.2
'20130501' 'BCO' 0.4 0.9
'20130601' 'BCO' 0.6 0.6
'20130701' 'BCO' 0.2
'20130801' 'BCO' 0.7 0.1
'20130901' 'BCO' 0.9 0.4
'20131001' 'BCO' 0.7 0.5
'20131101' 'BCO' 0.5
'20130701' 'WGO' 0.1
'20130801' 'WGO' 0.7
'20130901' 'WGO' 0.8
'20131001' 'WGO' 0.1 0.9
'20131101' 'WGO' 0.2 0.8
'20131201' 'WGO' 0.6 0.5
我需要计算每个分数的每个日期的行情自动收录器的数量。
即
AS_OF_DATE Count of SCORE_2 Count of SCORE_1
'20130601' 1 1
'20130701' 1 1
'20130801' 1 2
'20130901' 1 2
'20131001' 1 1
'20131101' 1
我一直在尝试使用GROUP BY和COUNT而不成功。谢谢!!!
SELECT COUNT(table.TICKER),
table.AS_OF_DATE,
table.SCORE_1,
table.SCORE_2
FROM table WHERE RowNum <= 200
GROUP BY table.AS_OF_DATE
答案 0 :(得分:0)
SELECT table.AS_OF_DATE,
COUNT(table.SCORE_2) "Count of SCORE_2",
COUNT(table.SCORE_1) "Count of SCORE_1"
FROM table
WHERE RowNum <= 200
GROUP BY table.AS_OF_DATE
COUNT函数计算非空属性的数量。关于COUNT的另一点是它返回的不是空值,因此在您的情况下,您将看到的不是空值,而是0。