日期:2014-05-17  浏览次数:20845 次

PL/sql 里对日期字段2012-2-3 这样的怎样查询出只显示年份的?因为有好多不同年份的
sql = "select tad,sum(weight) weight from( select substr(t.TEAMDATE,1,4) tad,t.weight from vw_pro_trainwork t where substr(t.TEAMDATE,1,4) in(to_char(sysdate,'yyyy')-2,to_char(sysdate,'yyyy')-1,to_char(sysdate,'yyyy'))) group by tda order by tda";



我这样写错了,该如何修改

------解决方案--------------------
SQL code
substr(t.TEAMDATE,1,4)  

改为:

to_char(t.TEAMDATE,'yyyy')