结果如下:
年龄 人数
30 23
31 15
34 23
.....
年龄 人数
30 23
31 15
34 23
.....
解决方案 »
- SQLserver2008 如何 自动定时维护 索引碎片
- 像这样一个网站http://www.ps3cha.com/要开发并维护一年的话需要多少钱呢?
- 数据类型怎么转换呢?
- C++ 操作数据库 查询mysql_query select from where中字段名等于变量的问题
- 一个求值的查询求助,比较简单,谢谢!
- 请教SQL2000对Oracle9i设置链接服务器是不是还要安装一下组件
- powerdesigner生成的数据库脚本在sql中运行出现的不允许有扩展属性或者不存在对象等问题
- 我觉得有点难且有趣的问题:怎样用SQL语言返回结果,使DBCHART形成饼图?
- sql server7.0中找不着系统表??
- 取上个月的记录,那如果当前是1月份,上个月是去年12月份,怎么取记录?
- 记录集数据不能更新
- 求特殊排序方法
from 表
group datediff(yy,生日,getdate())
from talbe1
group by yearold
group by datediff(yy,birth,getdate())
select count(*) , datediff(month,birth,getdate())/12 as a from @t
group by datediff(month,birth,getdate())/12
from 员工表
group by datediff(year,出生年月,getdate())
case when datediff(yy,'20060406',getdate()) > 0 and (datediff(mm,'20060406',getdate()) < 12)
then datediff(yy,'20060406',getdate()) - 1
when datediff(yy,'20060406',getdate()) = 0 and datediff(mm,'20060406',getdate()) < 12 then 0
else datediff(yy,'20060406',getdate()) end as 年龄,count(*) as 人数
from table1
case when datediff(yy,出生年月,getdate()) > 0 and (datediff(mm,出生年月,getdate()) < 12)
then datediff(yy,出生年月,getdate()) - 1
when datediff(yy,出生年月,getdate()) = 0 and datediff(mm,出生年月,getdate()) < 12 then 0
else datediff(yy,出生年月,getdate()) end as 年龄,count(*) as 人数
from table1
select case when datediff(mm,出生年月,getdate()) < 12 then 0
else datediff(yy,出生年月,getdate()) end as 年龄,count(*) as 人数
from table1