티스토리 뷰

WEB TIP/MS-SQL

연령별 집계

제프 2007. 4. 30. 18:21
SELECT [총   ] = count(age)
     , [10대] = count(case when age/10=1 then 1 end)
     , [20대] = count(case when age/10=2 then 1 end)
     , [30대] = count(case when age/10=3 then 1 end)
     , [40대] = count(case when age/10=4 then 1 end)
     , [50대] = count(case when age/10=5 then 1 end)
     , [60대] = count(case when age/10=6 then 1 end)
     , [70대] = count(case when age/10=7 then 1 end)
     , [80대] = count(case when age/10=8 then 1 end)
     , [90대] = count(case when age/10=9 then 1 end)
FROM TABLE

'WEB TIP > MS-SQL' 카테고리의 다른 글

Transact SQL 최적화 팁  (0) 2007.11.21
인덱스  (0) 2007.10.30
지역별 집계  (0) 2007.04.30
요일별 집계  (0) 2007.04.30
날짜 변경  (0) 2007.04.05
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/03   »
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
31
글 보관함