可以使用group语句. select 日期,方式,sum(数量) from yourtable group by 日期,方式 ========================================= 这样可以实现统计的效果,但是不是您所需的每一天一条记录. 楼上同学说使用游标,我觉得不大可行.要是真能统计出来只能说明我见识少了.请指教吧.
嘻嘻,需要表头,没看到..... select 日期,方式,sum(数量) as 数量统计 from yourtable group by 日期,方式
我做出来了, 谢谢各位! select (select sum(数量)from table where 方式1 and t1.日期=t2.日期)方式1总和, (select sum(数量)from table where 方式2 and t1.日期=t2.日期)方式2 总和, ... from tabel1 t1 ,(select distinct 日期 from table ) t2
select 日期,方式,sum(数量) from yourtable group by 日期,方式
=========================================
这样可以实现统计的效果,但是不是您所需的每一天一条记录.
楼上同学说使用游标,我觉得不大可行.要是真能统计出来只能说明我见识少了.请指教吧.
select 日期,方式,sum(数量) as 数量统计 from yourtable group by 日期,方式
select (select sum(数量)from table where 方式1 and t1.日期=t2.日期)方式1总和,
(select sum(数量)from table where 方式2 and t1.日期=t2.日期)方式2 总和,
...
from tabel1 t1 ,(select distinct 日期 from table ) t2
http://www.csdn.net/Expert/FAQ/FAQ_Index.asp?id=1517