I am getting error while executing this below hql query. Below is the query in hql and the error message its generating. Please suggest the changes
String query = "SELECT " +
"c " +
" FROM (select DISTINCT " +
"b " +
"FROM (select " +
"a.gcsAccountId, " +
"a.msisdn, " +
"a.partnerCode as bankID," +
"0 as processingStatus from ( select min(additionDate) fechaAfilia, a.gcsAccountId, a.partnerCode, a.msisdn from RGcscustomerAccountM c, " +
"RGcscustomerFundingAcctMp a, MonthlyGcsBillPaymentL mf where c.gcsAccountId=a.gcsAccountId and a.status ='A' and c.status='A' and " +
"mf.gcsAccountId = a.gcsAccountId and mf.collectorStatus in (0,1)and coalesce(mf.monthlyBillAmount,0)<> 0 " +
"group by a.partnerCode,a.gcsAccountId, a.msisdn order by a.gcsAccountId, a.msisdn, fechaAfilia)a where (a.fechaAfilia, a.gcsAccountId, a.msisdn) " +
"in (select min(fechaAfilia), gcsAccountId,msisdn from (select min(additionDate) fechaAfilia, a.gcsAccountId, a.partnerCode, a.msisdn from RGcscustomerAccountM c, " +
"RGcscustomerFundingAcctMp a where c.gcsAccountId=a.gcsAccountId and a.status ='A' and c.status='A' and c.gcsAccountId = a.gcsAccountId group by a.partnerCode, " +
"a.gcsAccountId, a.msisdn order by a.gcsAccountId, a.msisdn, fechaAfilia) group by gcsAccountId,msisdn ) union all select a.gcsAccountId, a.msisdn ,a.partnerCode, " +
"0 as processingStatus from ( select min(additionDate) fechaAfilia, a.gcsAccountId, a.partnerCode, a.msisdn from RGcscustomerAccountM c, RGcscustomerFundingAcctMp " +
"a,FtNsfTL nsf,FtTransferTO t where c.gcsAccountId=a.gcsAccountId and a.status ='A' and c.status='A' and nsf.gcsAccountId=a.gcsAccountId and nsf.nsfAmount<> 0 " +
"and nsf.isNsfHandledStatus in(0,1)and nsf.gcsAccountId = t.gcsAccountId and nsf.gcsSequenceNo = t.gcsSequenceNo and t.msisdn = a.msisdn group " +
"by a.partnerCode,a.gcsAccountId, a.msisdn order by a.gcsAccountId, a.msisdn, fechaAfilia) a where (a.fechaAfilia,a.gcsAccountId, a.msisdn) " +
"in( select MIN(fechaAfilia), gcsAccountId, msisdn from( select min(additionDate) fechaAfilia,a.gcsAccountId, a.partnerCode,a.msisdn from RGcscustomerAccountM " +
"c, RGcscustomerFundingAcctMp a WHERE c.gcsAccountId = a.gcsAccountId AND a.status = 'A' AND c.status = 'A' GROUP BY a.partnerCode, a.gcsAccountId, " +
"a.msisdn ORDER BY a.gcsAccountId, a.msisdn, fechaAfilia) GROUP BY " +
"gcsAccountId, " +
"msisdn " +
")) b " +
"WHERE " +
"b.bankID= 57 ORDER BY gcsAccountId ) c ";
This is the error, its showing, possibly something is missing.
unexpected token: ( near line 1, column 16 [SELECT c FROM (select DISTINCT b FROM (select a.gcsAccountId, a.msisdn, a.partnerCode as bankID,0 as processingStatus from ( select min(additionDate) fechaAfilia, a.gcsAccountId, a.partnerCode, a.msisdn from
This is the changed query.
String query = "SELECT " +
"c.gcsAccountId,c.msisdn,c.bankID,c.processingStatus FROM (select DISTINCT b.gcsAccountId,b.msisdn,b.bankID,b.processingStatus FROM (select "+
"a.gcsAccountId, " +
"a.msisdn, " +
"a.partnerCode as bankID," +
"0 as processingStatus from ( select min(additionDate) fechaAfilia, a.gcsAccountId, BankId as a.partnerCode , a.msisdn from RGcscustomerAccountM c, " +
"RGcscustomerFundingAcctMp a, MonthlyGcsBillPaymentL mf where c.gcsAccountId=a.gcsAccountId and a.status ='A' and c.status='A' and " +
"mf.gcsAccountId = a.gcsAccountId and mf.collectorStatus in (0,1)and coalesce(mf.monthlyBillAmount,0)<> 0 " +
"group by a.partnerCode,a.gcsAccountId, a.msisdn order by a.gcsAccountId, a.msisdn, fechaAfilia)a where (a.fechaAfilia, a.gcsAccountId, a.msisdn) " +
"in (select min(fechaAfilia), gcsAccountId,msisdn from (select min(additionDate) fechaAfilia, a.gcsAccountId, a.partnerCode, a.msisdn from RGcscustomerAccountM c, " +
"RGcscustomerFundingAcctMp a where c.gcsAccountId=a.gcsAccountId and a.status ='A' and c.status='A' and c.gcsAccountId = a.gcsAccountId group by a.partnerCode, " +
"a.gcsAccountId, a.msisdn order by a.gcsAccountId, a.msisdn, fechaAfilia) group by gcsAccountId,msisdn ) union all select a.gcsAccountId, a.msisdn ,a.partnerCode, " +
"0 as processingStatus from ( select min(additionDate) fechaAfilia, a.gcsAccountId, a.partnerCode, a.msisdn from RGcscustomerAccountM c, RGcscustomerFundingAcctMp " +
"a,FtNsfTL nsf,FtTransferTO t where c.gcsAccountId=a.gcsAccountId and a.status ='A' and c.status='A' and nsf.gcsAccountId=a.gcsAccountId and nsf.nsfAmount<> 0 " +
"and nsf.isNsfHandledStatus in(0,1)and nsf.gcsAccountId = t.gcsAccountId and nsf.gcsSequenceNo = t.gcsSequenceNo and t.msisdn = a.msisdn group " +
"by a.partnerCode,a.gcsAccountId, a.msisdn order by a.gcsAccountId, a.msisdn, fechaAfilia) a where (a.fechaAfilia,a.gcsAccountId, a.msisdn) " +
"in( select MIN(fechaAfilia), gcsAccountId, msisdn from( select min(additionDate) fechaAfilia,a.gcsAccountId, a.partnerCode,a.msisdn from RGcscustomerAccountM " +
"c, RGcscustomerFundingAcctMp a WHERE c.gcsAccountId = a.gcsAccountId AND a.status = 'A' AND c.status = 'A' GROUP BY a.partnerCode, a.gcsAccountId, " +
"a.msisdn ORDER BY a.gcsAccountId, a.msisdn, fechaAfilia) GROUP BY " +
"gcsAccountId, " +
"msisdn " +
")) b " +
"WHERE " +
"b.bankID= 68 ORDER BY gcsAccountId ) c ";
SELECT c FROM (select DISTINCT b FROM (select ...
Well, you're selecting c
from a subquery which returns distinct b
. That won't work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.