从表年明智地显示记录

时间:2012-03-25 20:28:12

标签: oracle timestamp

select station_id,count(case_id) from emer_complaint group by station_id

以上查询返回正确的结果。但是,当我尝试这个查询以显示年度记录时。然后它显示错误ORA-00904: "YEAR": invalid identifier

select year(date_time)
      ,count(case_id) 
 from emer_complaint  
group by year(date_time);

date_time的数据类型为Timestamp

提前致谢。!!

1 个答案:

答案 0 :(得分:0)

select to_char(date_time, 'YYYY'), count(case_id)
from   emer_complaint
group by to_char(date_time, 'YYYY');