본문 바로가기

프로그래밍/mysql

mysql - 누적값 조회

반응형

select a.sRegDate, a.nAntenna, sum(b.nAntenna) sum_ant
from
(
select sRegDate, sum(nAntenna) nAntenna
from tbl_antuse_his
where sRegDate <> '20070227'
group by sRegDAte
) a,
(
select sRegDate, sum(nAntenna) nAntenna
from tbl_antuse_his
where sRegDate <> '20070227'
group by sRegDAte
) b

where b.sRegDate <= a.sRegDate
group by a.sRegDate, a.nAntenna

반응형