Select TABLE1.x_ID,SUM(TABLE1.x_sale) AS sumsalein FROM table1 WHERE (TABLE1.x_date BETWEEN '"&2009-12-01
&"' AND '"&2009-12-03&"') GROUP BY TABLE1.x_ID
union
select '总和',sum(table1.x_sale) as sumsalein from table1 where (TABLE1.x_date BETWEEN '"&2009-12-01
&"' AND '"&2009-12-03&"')
select 订单ID ,sum(金额) from 订单表 --假设以订单ID汇总,订单ID和金额都是订单表里的字段
group by 订单ID
select
sum(case when x_id='A' then x_sale End) As SumA,
sum(case when x_id='B' then x_sale End) As SumB,
sum(case when x_id='C' then x_sale End) As SumC,
sum( x_sale ) As SumAll
From Where……
select x_id,sum(x_sale)
from 表名
where x_date between to_date('20091201','yyyymmdd') and to_date('20091203','yyyymmdd')
group by x_id