交叉查询的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
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
相关文章推荐
- 配置数据库连接
- 省市联动菜单的源代码实现(access数据库版)
- 数据库处理工具软件---sql explorer
- Oracle 基本知识
- Oracle 8.1.6 for Win2000 系统文件解释
- Oracle数据字典
- 利用PL/SQL打印ASCII表?
- 如何用SQL生成SQL批处理文件?
- Oracle中如何实现某一字段自动增加1?
- 怎样在SQL*Plus中使用 '&' 来实现自定义参数变量?
- 如何在PL/SQL中读写文件?
- Oracle常用Script
- 如何通过 SQL*PLUS 将符号 & 、'号(单引号) 插入ORACLE数据库的表中?
- 当MySQL集群时, JDBC路径的使用方法.
- 自动备份Oracle数据库
- Oracle数据库的备份与恢复
- 如何把数据exp到Sql loader里
- 提高ORACLE数据库系统import性能
- 国内ORACLE相关站点
- 工作总算有点变色了