가로, 세로 합 구하기 쿼리, dummy Table 사용함
제목 : 가로, 세로 합 구하기 쿼리, dummy Table 사용함
select
case when cnt=1 then RegiUser else '통계' end as '구매자'
,SUM(case when LEFT(ExhiApplNo, 8) = '20130525' then HopeAmt else 0 end) as '20130525'
,SUM(case when LEFT(ExhiApplNo, 8) = '20130526' then HopeAmt else 0 end) as '20130526'
,SUM(case when LEFT(ExhiApplNo, 8) = '20130527' then HopeAmt else 0 end) as '20130527'
,SUM(case when LEFT(ExhiApplNo, 8) = '20130528' then HopeAmt else 0 end) as '20130528'
,SUM(case when LEFT(ExhiApplNo, 8) = '20130529' then HopeAmt else 0 end) as '20130529'
,SUM(case when LEFT(ExhiApplNo, 8) = '20130530' then HopeAmt else 0 end) as '20130530'
,SUM(case when LEFT(ExhiApplNo, 8) = '20130601' then HopeAmt else 0 end) as '20130601'
,SUM(case when LEFT(ExhiApplNo, 8) = '20130602' then HopeAmt else 0 end) as '20130602'
,SUM(HopeAmt) as '합계'
from Au_ExhiRegi,
( select 1 cnt union all select 2
) 짝퉁테이블
group by case when cnt=1 then RegiUser else '통계' end
내용 :
예제 소스 파일 :
출처 :