연령대별 통계, 10대, 20대 > db

본문 바로가기

db

연령대별 통계, 10대, 20대

페이지 정보

작성자 서방님 댓글 1건 조회 13회 작성일 09-04-08 17:07

본문

Select
 Count(Case When Year(GetDate()) - Convert(Int, Case SubString(E.PersonalID, 7, 1) When 1 Then 1900 When 2 Then 1900 When 3 Then 2000 When 4 Then 2000 End + Convert(Int, Left(E.PersonalID, 2))) Between 10 And 19 Then 1 End) As '10대'
 , Count(Case When Year(GetDate()) - Convert(Int, Case SubString(E.PersonalID, 7, 1) When 1 Then 1900 When 2 Then 1900 When 3 Then 2000 When 4 Then 2000 End + Convert(Int, Left(E.PersonalID, 2))) Between 20 And 29 Then 1 End) As '20대'
 , Count(Case When Year(GetDate()) - Convert(Int, Case SubString(E.PersonalID, 7, 1) When 1 Then 1900 When 2 Then 1900 When 3 Then 2000 When 4 Then 2000 End + Convert(Int, Left(E.PersonalID, 2))) Between 30 And 39 Then 1 End) As '30대'
 , Count(Case When Year(GetDate()) - Convert(Int, Case SubString(E.PersonalID, 7, 1) When 1 Then 1900 When 2 Then 1900 When 3 Then 2000 When 4 Then 2000 End + Convert(Int, Left(E.PersonalID, 2))) Between 40 And 49 Then 1 End) As '40대'
 , Count(Case When Year(GetDate()) - Convert(Int, Case SubString(E.PersonalID, 7, 1) When 1 Then 1900 When 2 Then 1900 When 3 Then 2000 When 4 Then 2000 End + Convert(Int, Left(E.PersonalID, 2))) Between 50 And 59 Then 1 End) As '50대'
 , Count(Case When Year(GetDate()) - Convert(Int, Case SubString(E.PersonalID, 7, 1) When 1 Then 1900 When 2 Then 1900 When 3 Then 2000 When 4 Then 2000 End + Convert(Int, Left(E.PersonalID, 2))) Between 60 And 69 Then 1 End) As '60대'
 , Count(Case When Year(GetDate()) - Convert(Int, Case SubString(E.PersonalID, 7, 1) When 1 Then 1900 When 2 Then 1900 When 3 Then 2000 When 4 Then 2000 End + Convert(Int, Left(E.PersonalID, 2))) Between 70 And 79 Then 1 End) As '70대'
From TempTable




http://seobangnim.com/zbxe/15347

댓글목록

등록된 댓글이 없습니다.

Total 447건 1 페이지
게시물 검색

회원로그인

접속자집계

오늘
174
어제
365
최대
592
전체
40,148

그누보드5
Copyright © seobangnim.com All rights reserved.
자바스크립트를 활성화 하세요![ 브라우저에서 자바스크립트를 활성화하는 방법 ]