动态报告查询错误

时间:2016-03-26 10:06:23

标签: java

我的查询:

String query = "SELECT bs.origin, bs.destination, SUM(t.noofticket) as noofticket, SUM(p.totalAmount) as totalprice"
                  + " FROM transactions t, busSchedule bs, payment p"
                  + " WHERE t.BUSSCHEDULEID = bs.BUSSCHEDULEID"
                  + " AND t.TRANSACTIONSID = p.TRANSACTIONSID"
                  + " AND t.transactionsStatus = 'paid'"
                  + " AND (SUBSTRING(p.paymentdate,4)) = '"+choosenMonthlyMonth+"-"+choosenMonthlyYear+"'"
                  + " GROUP by origin,destination";

错误:

Caused by: net.sf.jasperreports.engine.JRException: Error preparing statement for executing the report query:

SELECT bs.origin, bs.destination, SUM(t.noofticket) as noofticket, SUM(p.totalAmount) as totalprice FROM transactions t, busSchedule bs, payment p WHERE t.BUSSCHEDULEID = bs.BUSSCHEDULEID AND t.TRANSACTIONSID = p.TRANSACTIONSID AND t.transactionsStatus = 'paid' AND (SUBSTRING(p.paymentdate,4)) = '03-2016' GROUP by origin,destination

大多数情况下,我认为这是由where子句中的SubString引起的。无论如何在where子句中使用substring?

ps:我还是jasper报道的新手

-update- 我能够通过将substring改为substr。

来解决它

谢谢。

0 个答案:

没有答案