【问题标题】:showing record from table year wise逐年显示表中的记录
【发布时间】:2012-03-25 20:28:12
【问题描述】:
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

先谢谢了!!

【问题讨论】:

  • 您需要to_charYear() 不是 Oracle 函数。
  • 感谢@Ben 的宝贵帮助!!

标签: oracle timestamp


【解决方案1】:
select to_char(date_time, 'YYYY'), count(case_id)
from   emer_complaint
group by to_char(date_time, 'YYYY');

【讨论】:

  • 它有效!但是,它返回1-JAN-2012。所以,我按照 Ben 的建议使用了 to_char。谢谢你的帮助!!
猜你喜欢
  • 2014-06-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-08
  • 1970-01-01
  • 2012-12-19
  • 1970-01-01
  • 2016-02-19
相关资源
最近更新 更多