Select ID,A_NUMBER=(Select sum(A_NUMBER) From table where t1.id=table.id and
Where A_TIME between @startDate and @EndDate),
B_NUMBER=(Select Sum(B_NUMBER) from table where table.id=t1.id and
Where B_TIME between @startDate and @EndDate),
C_NUMBER=(Select sum(C_NUMBER) from table where table.id=t1.id) and
Where C_TIME between @startDate and @EndDate)
From table as t1
group by ID
Where A_TIME between @startDate and @EndDate),
B_NUMBER=(Select Sum(B_NUMBER) from table where table.id=t1.id and
Where B_TIME between @startDate and @EndDate),
C_NUMBER=(Select sum(C_NUMBER) from table where table.id=t1.id) and
Where C_TIME between @startDate and @EndDate)
From table as t1
group by ID
form tablename
group by id
from 表
where 时间段
group by id
from
(select ID,A_NUMBER=sum(A_NUMBER)
from tb
where A_TIME between @B_TIME and @E_YIME
group by ID) a
left join
(select ID,B_NUMBER=sum(B_NUMBER)
from tb
where B_TIME between @B_TIME and @E_YIME
group by ID) b
on a.ID=b.ID
left join
(select ID,C_NUMBER=sum(C_NUMBER)
from tb
where C_TIME between @B_TIME and @E_YIME
group by ID) c
on a.ID=c.ID