如何选择在列中显示更多次数的日期

时间:2013-08-24 10:56:02

标签: sql oracle

例如:

表是

date                      bill amount
12/06/2013                  200
12/06/2013                  920
15/06/2013                  300

输出

date                    bill amount
12/06/2013                  1120
15/06/2013                  300

4 个答案:

答案 0 :(得分:2)

这是SQLFiddle

 SELECT date, SUM(billamount)
   FROM tab1 GROUP BY date;

答案 1 :(得分:0)

使用 group by 来实现目标。

答案 2 :(得分:0)

SELECT theDate, COUNT(theDate) AS NumOccurrences

FROM someTable GROUP BY theDate

HAVING ( COUNT(theDate) > 1 )

答案 3 :(得分:0)

sqlfiddle

select d as "date",
       sum(amount) as "bill amount", 
       count(*) as "count" 
from T
group by d
having count(*) > 0 --change zero to occurrence number you wish
order by d;

sqlfiddle

enter image description here