Author |
Topic |
vipin_jha123
Starting Member
31 Posts |
Posted - 2011-03-17 : 02:39:31
|
Dear Sir ,I have a question that the query given bbelow is running but showing no result(data).when i am running the corelated query in partwise then it shows the data:-Select SST.sol_id, SST.set_id, GAM.sol_id, SOL.sol_desc, GAM.foracid, GAM.acct_name, GAM.cif_id, GAC.free_text_1, SMT.acct_status As " SBA/CAA schemes", CAM.acct_status As "ODA/CCA schemes", GAM.acct_cls_flg As " closedstatus", GAM.frez_code, GAM.frez_reason_code As " freeze status", GAM.acct_opn_date, dctd_acli.tran_amt, GAM.clr_bal_amt, (Select Sum(dctd_acli.tran_amt) From TBAADM.dctd_acli Where TBAADM.dctd_acli.PART_TRAN_TYPE = 'D') As "Total Dr Amt", (Select Sum(dctd_acli.tran_amt) From TBAADM.dctd_acli Where TBAADM.dctd_acli.PART_TRAN_TYPE = 'C') As "Total Cr Am", (Select Count(dctd_acli.tran_id) From TBAADM.dctd_acli) As "Tran Cnt", (Select Sum(dctd_acli.tran_amt) From TBAADM.dctd_acli Where TBAADM.dctd_acli.PART_TRAN_TYPE = 'C') As "Total Cash Deposit", (Select Sum(dctd_acli.tran_amt) From TBAADM.dctd_acli Where TBAADM.dctd_acli.PART_TRAN_TYPE = 'L') As "Total Clearing ", (Select Sum(dctd_acli.tran_amt) From TBAADM.dctd_acli Where TBAADM.dctd_acli.PART_TRAN_TYPE Not In ('C', 'L')) As "Others"From TBAADM.SST, TBAADM.SOL, TBAADM.GAM, TBAADM.GAC, TBAADM.DCTD_ACLI, TBAADM.EAB, TBAADM.CAM, TBAADM.SMTWhere GAM.acid = dctd_acli.acid And GAM.acid = SMT.acid And GAM.acid = CAM.acid And GAM.acid = GAC.acid And GAM.bank_id = dctd_acli.bank_id And GAM.bank_id = SMT.bank_id And GAM.bank_id = CAM.bank_id And GAM.bank_id = GAC.bank_id And GAM.del_flg = 'N' And GAM.entity_cre_flg = 'Y' And SST.del_flg = 'N' And SST.entity_cre_flg = 'Y' And EAB.tran_date_bal > 50000Group By SST.sol_id, SST.set_id, GAM.sol_id, SOL.sol_desc, GAM.foracid, GAM.acct_name, GAM.cif_id, GAC.free_text_1, SMT.acct_status, CAM.acct_status, GAM.acct_cls_flg, GAM.frez_code, GAM.frez_reason_code, GAM.acct_opn_date, dctd_acli.tran_amt, GAM.clr_bal_amtOrder By GAM.sol_id, EAB.eod_dateplease help me in same.........thanks in advanceVipin jha |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2011-03-17 : 08:31:06
|
Your query is fundamentally wrong. Here is your query rewritten in ANSI way and I performance tuned your aggregations.SELECT SST.sol_id, SST.set_id, GAM.sol_id, SOL.sol_desc, GAM.foracid, GAM.acct_name, GAM.cif_id, GAC.free_text_1, SMT.acct_status As [SBA/CAA schemes], CAM.acct_status As [ODA/CCA schemes], GAM.acct_cls_flg As [closed status], GAM.frez_code, GAM.frez_reason_code As [freeze status], GAM.acct_opn_date, dctd_acli.tran_amt, GAM.clr_bal_amt, SUM(CASE WHEN TBAADM.dctd_acli.PART_TRAN_TYPE = 'D' THEN dctd_acli.tran_amt ELSE 0 END) As [Total Dr Amt], SUM(CASE WHEN TBAADM.dctd_acli.PART_TRAN_TYPE = 'C' THEN dctd_acli.tran_amt ELSE 0 END) As [Total Cr Am], SUM(CASE WHEN dctd_acli.tran_id IS NULL THEN 0 ELSE 1 END) AS [Tran Cnt], SUM(CASE WHEN TBAADM.dctd_acli.PART_TRAN_TYPE = 'C' THEN dctd_acli.tran_amt ELSE 0 END) As [Total Cash Deposit], SUM(CASE WHEN TBAADM.dctd_acli.PART_TRAN_TYPE = 'L' THEN dctd_acli.tran_amt ELSE 0 END) As [Total Clearing], SUM(CASE WHEN TBAADM.dctd_acli.PART_TRAN_TYPE IN ('C', 'L') THEN 0 ELSE dctd_acli.tran_amt END) As OthersFROM TbaAdm.GAMINNER JOIN TbaAdm.SMT ON SMT.acid = GAM.acid AND SMT.bank_id = GAM.bank_idINNER JOIN TbaAdm.SST ON SST.del_flg = 'N' -- Missing reference to outer table And SST.entity_cre_flg = 'Y'INNER JOIN TbaAdm.SOL -- Missing reference to outer tableINNER JOIN TbaAdm.GAC ON GAC.acid = GAM.acid AND GAC.bank_id = GAM.bank_idINNER JOIN TbaAdm.DCTD_ACLI ON dctd_acli.acid = GAM.acid AND dctd_acli.bank_id = GAM.bank_idINNER JOIN TbaAdm.EAB ON EAB.tran_date_bal > 50000 -- Missing reference to outer tableINNER JOIN TbaAdm.CAM ON CAM.acid = GAM.acid AND CAM.bank_id = GAM.bank_idWHERE GAM.del_flg = 'N' AND GAM.entity_cre_flg = 'Y'GROUP BY SST.sol_id, SST.set_id, GAM.sol_id, SOL.sol_desc, GAM.foracid, GAM.acct_name, GAM.cif_id, GAC.free_text_1, SMT.acct_status, CAM.acct_status, GAM.acct_cls_flg, GAM.frez_code, GAM.frez_reason_code, GAM.acct_opn_date, dctd_acli.tran_amt, GAM.clr_bal_amtORDER BY GAM.sol_id, EAB.eod_date N 56°04'39.26"E 12°55'05.63" |
|
|
|
|
|