SELECT COUNT(*),updateTime FROM Table
GROUP BY
YEAR(updateTime)
sql 正常。但
SELECT COUNT(id),o.updateTime FROM Table o
GROUP BY
YEAR(o.updateTime)貌似Group by 之后的year不支持。去掉year 单独o.updateTime可以。
我的意图就是如上sql,查询每年成交量 ,请问hibernate里面怎么搞?有什么解决方法!
GROUP BY
YEAR(updateTime)
sql 正常。但
SELECT COUNT(id),o.updateTime FROM Table o
GROUP BY
YEAR(o.updateTime)貌似Group by 之后的year不支持。去掉year 单独o.updateTime可以。
我的意图就是如上sql,查询每年成交量 ,请问hibernate里面怎么搞?有什么解决方法!
还是不行。有人貌似提出过这个问题。http://www.cnblogs.com/a-peng/archive/2010/02/06/1665042.htmlGROUP BY之后不能加函数.
YEAR(o.updateTime)
但貌似没有解决方法。
你试试这样做可不可以:
from tableEntity group by to_char('yyyy')
数据库 Mysql
使用hibernate 数据表table
id updateTime
1 2010-09-09
2 2010-09-09
3 2010-10-01
....
GROUP BY
YEAR(o.updateTime)
以上没问题。问题出在QuerySyntaxException: expecting CLOSE, found '(' near line 1, column 27 [select count(DISTINCT year(o.updateTime)) from com.xxx.bean.Price o]
select count(DISTINCT year(o.updateTime)) from com.xxx.bean.Price o
这句出了问题。select count(DISTINCT o.updateTime) from com.xxx.bean.Price o 这样没问题。
莫非count distinct里面不能在家year?
晕倒。这句提示少了 ( 貌似没有却少哇。谁帮我看看