当前位置: 代码迷 >> Oracle开发 >> hql按月分组查询解决思路
  详细解决方案

hql按月分组查询解决思路

热度:89   发布时间:2016-04-24 06:48:20.0
hql按月分组查询
String hql = "select count(*) from RawCaseRecorder where caseEndTime between '"+date1+"' and '"+date2+"' and punish_type_1 in('兽药行政处罚','饲料行政处罚') and caseType=3 group by  ";
  list = getHibernateTemplate().find(hql);
我想实现按月分组查询,请问大神我该怎么做,group  by后面的语句我该怎么写?
急,在线等,求指教!


------解决方案--------------------
group by to_char(caseEndTime,'mm')
------解决方案--------------------
引用:
Quote: 引用:

group by to_char(caseEndTime,'mm')
日期类型在数据库是保存为long类型的!

TO_DATE('19700101','yyyymmdd') + 
 caseEndTime/86400000 + TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))/24
这个long转date

  相关解决方案