Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如:
表是
日期账单金额 2013 年 12 月 6 日 200 2013 年 12 月 6 日 920 2013 年 6 月 15 日 300
输出是
日期账单金额 2013 年 12 月 6 日 1120 2013 年 6 月 15 日 300
这是SQLFiddle
SELECT date, SUM(billamount) FROM tab1 GROUP BY date;
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;
使用group by来实现您的目标。
SELECT theDate, COUNT(theDate) AS NumOccurrences FROM someTable GROUP BY theDate HAVING ( COUNT(theDate) > 1 )