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

解决方案 »

  1.   

    select id,sum(A_NUMBER) as A_NUMBER ,sum(B_NUMBER) as B_NUMBER ,sum(C_NUMBER) as C_NUMBER 
    form tablename
    group by id
      

  2.   

    select sum(a_number),sum(b_number),sum(c_number)
    from 表
    where 时间段
    group by id
      

  3.   

    select a.ID,A_NUMBER,B_NUMBER,C_NUMBER
    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