Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL How to?
Message
From
10/01/2007 15:35:38
 
 
To
10/01/2007 15:14:33
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01184347
Message ID:
01184361
Views:
12
>How can I combine the following into one SQL statement? The problem I am having is the majority of the data is coming from one table, but the criteria for each field is different.
>
>
>SELECT SUM(nloan_amount) as Total_Amt_CAP_Loans FROM loan.dbf WHERE UPPER(cstatus) = "ENROLLED" OR UPPER(cstatus) = "LOSS" OR UPPER(cstatus) = "PIF"
>
>SELECT SUM(nloan_amount) as Total_Amt_Enrolled_Loans FROM loan.dbf WHERE UPPER(cstatus) = "ENROLLED"
>
>SELECT SUM(nstate_reserve_payment) as nBDC_Reserve FROM loan.dbf WHERE UPPER(cstatus) = "ENROLLED" OR UPPER(cstatus) = "LOSS" OR UPPER(cstatus) = "PIF"
>
>SELECT SUM(nborrower_reserve_payment) + SUM(nlender_reserve_payment) as nBank_Borrower_Reserve FROM loan.dbf WHERE UPPER(cstatus) = "ENROLLED" OR UPPER(cstatus) = "LOSS" OR UPPER(cstatus) = "PIF"
>
>SELECT SUM(ytotal_claim_amount) as nClaims_Paid FROM claims.dbf
>
SELECT SUM(IIF(UPPER(cstatus)="ENROLLED",1,0)*nloan_amount) as  Total_Amt_Enrolled_Loans, ;
	SUM(nloan_amount) as Total_Amt_CAP_Loans,SUM(nstate_reserve_payment) as nBDC_Reserve, ;
	SUM(nborrower_reserve_payment+nlender_reserve_payment) as nBank_Borrower_Reserve, ;
	(SELECT SUM(ytotal_claim_amount) FROM claims)  as nClaims_Paid ;
	FROM loan WHERE INLIST(UPPER(cstatus),"ENROLLED","LOSS","PIF")
Edward Pikman
Independent Consultant
Previous
Reply
Map
View

Click here to load this message in the networking platform