我在 iReport 的报表查询向导中有以下查询
select docid_fname_pemid.*, MONTHNAME(b.ServicePeriodDate) as month_name,YEAR(b.ServicePeriodDate) as year_name , b.NonLTCMaximumSpecialPayment, b.NonLTCEnrolledPatientOutsideUseTotal, b.NonLTCAccessBonus
from (
select docid_pemid.PEMID, docid_pemid.DoctorID, b.$P{transparency_check})
from (
select DoctorID,PEMID from DoctorPEMMap where PEMID in ($P{PEMID_input}) and StartDate >= $P{StartDate} and (EndDate <= $P{EndDate} or EndDate <= '0000-00-00') group by PEMID order by PEMID
)docid_pemid left join Doctors b on docid_pemid.DoctorID=b.DoctorID
) docid_fname_pemid
left join DoctorPayments b on docid_fname_pemid.DoctorID=b.DoctorID
&参数,按顺序(参数类,提示是/否,默认值表达式)
1) PEMID_input
--> 字符串,提示是,否
2) month_year
--> .String,提示是,否
3) transparency_input
--> 字符串,提示是,否
4) transparency_check
-->字符串,无提示,($P{transparency_input}=="yes" ) ? ("FirstName") : ("AliasFirstName")
5) StartDate
-->字符串,无提示,$P{month_year}.split("-")[0]=="April" ? $P{month_year}.split("-")[1].concat("-04-01") : $P{month_year}.split("-")[1].concat("-10-01")
6) EndDate
-->字符串,无提示,$P{month_year}.split("-")[0]=="April" ? $P{month_year}.split("-")[1].concat("-09-30") : $P{month_year}.split("-")[1].concat("-03-31")
当我运行报告时,给出以下错误
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax to use near ''FirstName'
from ( select DoctorID,PEMID from DoctorPEMMap where PEMID in ('21' at line 3
在
我认为查询没有得到'b.FirstName'
。所以我使用 concat 函数 as concat('b.',$P{transparency_check})
,但它不起作用。
我最终想要b.FirstName
或b.AliasFirstName
像在 mysql 查询中一样。当我手动给出这些术语中的任何一个时,查询运行良好。
我该怎么走?