您的位置: 世界经理人> 世界计算机 > 数据库系统 > SQLSERVER

交叉查询的sql

世界计算机ICXO.COM ( 日期:2004-11-11 17:17)


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 gw

来源:
世界计算机

网友推荐
 关于SQLSERVER数据操作的常用类
 SQL核心语句(非常实用的几个技巧)
 PB SqlServer应用程序打
 SQL SERVER实用经验技巧集
 通过1433获取SQL Server版
 Microsoft SQL Serve