打印本文 打印本文 关闭窗口 关闭窗口
sql交叉查询
作者:武汉SEO闵涛  文章来源:敏韬网  点击数657  更新时间:2009/4/22 20:43:19  文章录入:mintao  责任编辑:mintao
sql:
select gwlb, count(case when (year(getdate())-year(rybirthday)) between 20 and 30 then rygh end) as '20-30',
count(case when (year(getdate())-year(rybirthday)) between 30 and 40 then rygh end) as '30-40',
count(case when (year(getdate())-year(rybirthday)) between 40 and 50 then rygh end) as '40-50',
count(case when (year(getdate())-year(rybirthday)) between 50 and 60 then rygh end) as '50-60',
count(case when (year(getdate())-year(rybirthday)) between 60 and 70 then rygh end) as '60-70'
from t_ry
group by gwlb

打印本文 打印本文 关闭窗口 关闭窗口