Click here to Skip to main content
15,887,464 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
select
rpad(a.farmer_code,6, ‘ ‘)code,
rpad(b.farmer_name,30, ‘ ‘)fname,
rpad(d.subcircle_name,25,’ ‘)cname,
rpad(c.village_name,20, ‘ ‘)vname,
rpad(a.bank_code,5,’ ‘)bid,
rpad(e.banK_name,40,’ ‘)bname,
rpad(a.Bank_acno,20, ‘ ‘)sbac,
rpad(a.net_payment,8,’ ‘)netpay
IF ({e.ISFC_CODE}) LIKE ("*ALLA*") AND Length ({a.BANK_ACNO})=11 then "CORRECT" else
IF({e.ISFC_CODE}) LIKE ("*UTIB*") AND Length ({a.BANK_ACNO})=15 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*BKID*") AND Length ({a.BANK_ACNO})=15 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*MAHB*") AND Length ({a.BANK_ACNO})=11 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*CNRB*") AND Length ({a.BANK_ACNO})=13 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*CBIN*") AND Length ({a.BANK_ACNO})=10 then "CORRECT" else
IF ({e. ISFC_CODE}) LIKE ("*CORP*") AND Length ({a.BANK_ACNO})=15 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*FDRL*") AND Length ({a.BANK_ACNO})=14 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*HDFC*") AND Length ({a.BANK_ACNO})=14 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*ICIC*") AND Length ({a.BANK_ACNO})=12 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*IOBA*") AND Length ({a.BANK_ACNO})=15 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*KARB*") AND Length ({a.BANK_ACNO})=16 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*KVGB*") AND Length ({a.BANK_ACNO})=11 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*SBIN*") AND Length ({a.BANK_ACNO})=11 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*SBMY*") AND Length ({a.BANK_ACNO})=11 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*SYNB*") AND Length ({a.BANK_ACNO})=14 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*RATN*") AND Length ({a.BANK_ACNO})=12 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*RATN*") AND Length ({a.BANK_ACNO})=16 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*UBIN*") AND Length ({a.BANK_ACNO})=15 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*VIJB*") AND Length ({a.BANK_ACNO})=15 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*BKDN*") AND Length (a.BANK_ACNO})=12 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*IDIB*") AND Length ({a.BANK_ACNO})=10 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*IDIB*") AND Length ({a.BANK_ACNO})=9 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*KAIJ*") AND Length ({a.BANK_ACNO})=15 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*VYSA*") AND Length ({a.BANK_ACNO})=12 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*SVCB*") AND Length ({a.BANK_ACNO})=15 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*ORBC*") AND Length ({a.BANK_ACNO})=14 then "CORRECT" else
IF ({e.ISFC_CODE}) LIKE ("*BARB*") AND Length ({a.BANK_ACNO})=14 then "CORRECT" else
IF ({e.ISFC_CODE})=("IBKL0101BDC") AND Length ({a.BANK_ACNO})=16 then "CORRECT" else
IF ({e.ISFC_CODE})=("IBKL0069RSB") AND Length ({a.BANK_ACNO})=15 then "CORRECT" else
IF ({e.ISFC_CODE})=("IBKL01071BD") AND Length ({a.BANK_ACNO})=15 then "CORRECT" else
IF ({e.ISFC_CODE})=("KSCB") AND Length ({a.BANK_ACNO})=12 then "CORRECT" else "WRONG"
From farmer_summary_prov a,farmer_master b,village_master c, subcircle_master d,bank_master e
Where a.farmer_code=b. farmer_code and
b.village_code=c.village_code and
c. SUBCIRCLE_CODE=d. SUBCIRCLE_CODE and
a.bank_code=e.bank_code
and a. net_payment>0
/
Posted
Comments
Jörgen Andersson 8-Dec-15 1:56am    
And your error is?
OriginalGriff 8-Dec-15 2:19am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
So we have your existing SQL, but not your data, or any idea what you expect it to do. We can't run it (because we don't have your data) so we can't even check it for syntax
errors except visually.

Use the "Improve question" widget to edit your question and provide better information.
Torakami 8-Dec-15 6:01am    
We do not provide optimization of sql service here.

As mentioned in the other post, don't do your from table1, table2 method. Use JOINS. See How I Can Write If Condition In Below Sql Query[^]

And change your IF to CASE statements. Very easy to do. Refer to my other answer as well.
 
Share this answer
 
I noticed that there is no comma after netpay just before the IFs.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900