3초기억력

가로, 세로 합 구하기 쿼리, dummy Table 사용함 본문

쿼리_MSSQL

가로, 세로 합 구하기 쿼리, dummy Table 사용함

잠수콩 2014. 6. 10. 11:14
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



제목 :  가로, 세로 합 구하기 쿼리, 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




내용 :



예제 소스 파일 :


 출처 :  


 

 

 

Comments