首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-02-21 
统计这样的年份!!!!!!!!!!!!!!!!!!!!!!!!timed(smalldatetime)2005-11-082005-11-102005-12-112006-11-082

统计这样的年份!!!!!!!!!!!!!!!!!!!!!!!!
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

热点排行