当前位置: 代码迷 >> Sql Server >> 统计这样的年份!解决方法
  详细解决方案

统计这样的年份!解决方法

热度:223   发布时间:2016-04-27 21:48:41.0
统计这样的年份!!!!!!!!!!!!!!!!!!!!!!!!
timed   (smalldatetime)
2005-11-08
2005-11-10
2005-12-11
2006-11-08
2006-11-10
2006-12-11
2007-11-08
2007-11-10
2008-12-11

怎么查询出来如下结果?
2005
2006
2007
2008




------解决方案--------------------
select year(timed),count(*) from 表 group by year(timed)
------解决方案--------------------

select year(timed) as timed from tbName
group by year(timed)
------解决方案--------------------
select distinct year(timed) from 表 order by timed
  相关解决方案