我有这个查询(在 mySQL cmdline 中运行良好),但是当我使用 executeQuery 在 grails 中运行它时,我收到了这个错误:时间格式错误
这是我的 grails 查询:
def aveTimeToClose = OstFacTicket.executeQuery
("SELECT SEC_TO_TIME(AVG(TIME_TO_SEC(TIMEDIFF(t.closed, t.created)))) as cl " +
"from OstFacTicket t WHERE t.created >= :sdate AND t.created <= :edate AND " +
"t.closed IS NOT NULL", [sdate:start, edate: end])
堆栈跟踪错误是:
Error 2012-05-17 00:09:44,356 [http-bio-8080-exec-9]
ERROR util.JDBCExceptionReporter
- Bad format for Time '187:22:05' in column 1
| Error 2012-05-17 00:09:44,365 [http-bio-8080-exec-9] ERROR errors.GrailsExceptionResolver
在 mySQL cmdline 上运行可以正常工作:
mysql> SELECT SEC_TO_TIME(AVG(TIME_TO_SEC(TIMEDIFF(t.closed, t.created)))) as cl
from ost_fac_ticket t where created > '2011-01-01 08:12:49' AND created <
'2011-12-31 10:12:49';
+-----------+
| cl |
+-----------+
| 187:22:05 |
+-----------+
谢谢,我很感激任何帮助。