티스토리 뷰
일자별로 집계가 필요한경우
일자무시하고 해당기간동안의 전체집계만 필요한 경우
DECLARE @조회시작일자 datetime , @조회종료일자 datetime SET @조회시작일자 = '2004-06-14' SET @조회종료일자 = '2004-06-18' SELECT isnull(count(case when substring(address,1,2) = '서울' then 1 end),0) as 서울 , isnull(count(case when substring(address,1,2) = '경기' then 1 end),0) as 경기 , isnull(count(case when substring(address,1,2) = '인천' then 1 end),0) as 인천 , isnull(count(case when substring(address,1,2) = '대전' then 1 end),0) as 대전 , isnull(count(case when substring(address,1,2) = '대구' then 1 end),0) as 대구 , isnull(count(case when substring(address,1,2) = '부산' then 1 end),0) as 부산 , isnull(count(case when substring(address,1,2) = '울산' then 1 end),0) as 울산 , isnull(count(case when substring(address,1,2) = '강원' then 1 end),0) as 강원 , isnull(count(case when substring(address,1,2) = '광주' then 1 end),0) as 광주 , isnull(count(case when substring(address,1,2) = '충북' then 1 end),0) as 충북 , isnull(count(case when substring(address,1,2) = '충남' then 1 end),0) as 충남 , isnull(count(case when substring(address,1,2) = '경남' then 1 end),0) as 경남 , isnull(count(case when substring(address,1,2) = '경북' then 1 end),0) as 경북 , isnull(count(case when substring(address,1,2) = '전남' then 1 end),0) as 전남 , isnull(count(case when substring(address,1,2) = '전북' then 1 end),0) as 전북 , isnull(count(case when substring(address,1,2) = '제주' then 1 end),0) as 제주 , count(*) as 총합 FROM TABLE WHERE writeday >= convert(char(10),@조회시작일자,120) AND writeday < convert(char(10),dateadd(dd,1,@조회종료일자),120) GROUP BY substring(writeday,1,10)
일자무시하고 해당기간동안의 전체집계만 필요한 경우
DECLARE @조회시작일자 datetime , @조회종료일자 datetime SET @조회시작일자 = '2004-06-14' SET @조회종료일자 = '2004-06-18' SELECT isnull(count(case when substring(address,1,2) = '서울' then 1 end),0) as 서울 , isnull(count(case when substring(address,1,2) = '경기' then 1 end),0) as 경기 , isnull(count(case when substring(address,1,2) = '인천' then 1 end),0) as 인천 , isnull(count(case when substring(address,1,2) = '대전' then 1 end),0) as 대전 , isnull(count(case when substring(address,1,2) = '대구' then 1 end),0) as 대구 , isnull(count(case when substring(address,1,2) = '부산' then 1 end),0) as 부산 , isnull(count(case when substring(address,1,2) = '울산' then 1 end),0) as 울산 , isnull(count(case when substring(address,1,2) = '강원' then 1 end),0) as 강원 , isnull(count(case when substring(address,1,2) = '광주' then 1 end),0) as 광주 , isnull(count(case when substring(address,1,2) = '충북' then 1 end),0) as 충북 , isnull(count(case when substring(address,1,2) = '충남' then 1 end),0) as 충남 , isnull(count(case when substring(address,1,2) = '경남' then 1 end),0) as 경남 , isnull(count(case when substring(address,1,2) = '경북' then 1 end),0) as 경북 , isnull(count(case when substring(address,1,2) = '전남' then 1 end),0) as 전남 , isnull(count(case when substring(address,1,2) = '전북' then 1 end),0) as 전북 , isnull(count(case when substring(address,1,2) = '제주' then 1 end),0) as 제주 , count(*) as 총합 FROM TABLE WHERE writeday >= convert(char(10),@조회시작일자,120) AND writeday < convert(char(10),dateadd(dd,1,@조회종료일자),120)
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Windows2003
- offline application cache
- ADO
- UTF-8
- 인덱스
- 문자열 분리
- c#
- case
- SQL
- injection
- 영어
- Git
- 암호화
- pang caching
- HttpCookie
- Visual Stuiod Team Services
- ASP.NET
- oracle
- IIS
- 폰트색상
- 오라클
- gitignore
- asp
- 숙취
- Convert
- index
- SEQUENCE
- jquery
- .NET Core
- MS-SQL
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
글 보관함