想在表中添加一个字段作为年份years,2015-01-02的对应字段years的值为2015,2019-01-02的对应字段years的值为2019
添加字段:ALTER TABLE 表名 ADD years varchar(4)
更新数据:update 表名 set years = year(Dates)
。。。
sql server:select *, year(Dates) as year from 表名
oracle:select *, to_number(to_char(t.hiredate,'yyyy')) as year from 表名
select left(Dates,4) as year from 表名