请问怎么从一个表中查出一个datetime型字段的所有不重复年份。 select distinct datepart(year, 日期字段) from table或者select datepart(year, 日期字段) from table group by datepart(year, 日期字段) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select distinct(left(字段,4)) from tablename select distinct datepart(y, 日期字段) from tablename select datepart(year, 字段) from table group by datepart(year, 字段) select datepart(year, 字段) from table group by datepart(year, 字段) SELECT distinct DATEname(yy, 字段名字) from tablename select distinct datepart(year, 日期字段) from table SELECT distinct DATEname(yy, 字段名字) as 年 from yourtable --更正select distinct datepart(yy, 日期字段) from tablenameor select distinct left(convert(varchar(10),日期字段,120),4) from tablename select distinct datepart(yy, 日期字段) from tablename select distinct datename(year,日期字段) from tablename select distinct datepart(yy, 日期字段) from tablename 我是菜鸟,请帮个帮,是关于插入记录(我新注册,没分) 一个关于CLR函数的性能问题,求解 江湖救急 SQL SERVER 2008 不能断开数据连接。 Visio生成数据库模型 SQL遍历 游标问题* 请教一条sql的写法 数据库从一台搬到另一台 同一张表中非主键,可空的列,可以允许两个GUID的列存在么? 这个的SQL语句如何写?!? 关于两个表间的数据. 这个问题好奇怪? 请教! 视图查询的问题
select distinct datepart(yy, 日期字段) from tablename
or
select distinct left(convert(varchar(10),日期字段,120),4) from tablename