您的位置:首页 > 数据库

交叉查询的sql

2004-11-11 10:03 405 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: