好像只是用别扭的方式写了sum,而group by 的功能没实现。 我看要用 select a,sum(b),sum(c) from DayReport order by a 其实好像也不行 用select a,sum(b),sum(c) from table1 t1 where a = (select top 1 * from table1 where t1.a=table1.a)
LoveSQL(努力奋斗ing),呵呵, select A, (select sum(B) from DayReport )as B, (select sum(c) DayReport )as C from DayReport这样显然不行啊, 我是要实现group by 的功能啊,你这样根本没有分组,统计的是全体数据。
Select a=z.A, b=(select sum(B) from DayReport where A=z.A), c=(select sum(C) from DayReport where A=z.A) from (select distinct A from DayReport) z
--这样的语句该支持吧?select A ,B=(select sum(B) from DayReport where A=a.A) ,C=(select sum(C) from DayReport where A=a.A) from(select distinct A from DayReport)a
我看要用
select a,sum(b),sum(c) from DayReport order by a
其实好像也不行
用select a,sum(b),sum(c) from table1 t1 where a = (select top 1 * from table1 where t1.a=table1.a)
select A, (select sum(B) from DayReport )as B, (select sum(c) DayReport )as C from DayReport这样显然不行啊, 我是要实现group by 的功能啊,你这样根本没有分组,统计的是全体数据。
b=(select sum(B) from DayReport where A=z.A),
c=(select sum(C) from DayReport where A=z.A)
from (select distinct A from DayReport) z
,B=(select sum(B) from DayReport where A=a.A)
,C=(select sum(C) from DayReport where A=a.A)
from(select distinct A from DayReport)a