我想获得以下范围(10-20、21-30、31-40)的计数和总和。我怎样才能修改这个查询来得到它?
select count (t.aaa), sum (t.bbb)
from xxx t
where t.qqq IN ('3')
and t.www like 'A'
and t.eee >= TO_DATE('2008/03/20','YYYY/MM/DD')
and t.eee <= TO_DATE('2009/03/21','YYYY/MM/DD')
and t.ttt >= 10 and t.ttt <= 20
输出应如下所示:
╔════════╦══════════════╦════════════╗
║ TRANGE ║ COUNT(t.aaa) ║ SUM(t.bbb) ║
╠════════╬══════════════╬════════════╣
║ 10-20 ║ 340 ║ 4981620000 ║
║ 21-30 ║ 239 ║ 3999425000 ║
║ 31-40 ║ 199 ║ 4076525000 ║
╚════════╩══════════════╩════════════╝