Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Complex select
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Complex select
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01132829
Message ID:
01132829
Views:
59
Hi everybody,

I'm trying to find open accounts that have calculated balance not matching the current balance in the Trans table.

Here is my current select statement:
SELECT Trans.yReferral_balance_amount, Trans.yCurrent_balance_amount, ;
	(SELECT SUM(Payments.yAmount_Paid) as yBalance ;
	FROM Payments inner join Trans Trans1 ;
	on Payments.cTrans_fk = Trans1.cTrans_pk ;
	WHERE Payments.cTrans_fk = Trans.cTrans_pk ;
	and Payments.dPosting_date > Trans1.tDate_received) ;
	as yTotalPayments ;	
   FROM TRANS ;
   WHERE Trans.cResolution_Codes_fk is NULL into cursor curAllBalances nofilter
The Calculated balance equals Referral Balance - All payments after received date.

I'm not sure how can I add this calculation into this SQL. Of course, I can do this in two steps, but is there a way to do in one step?

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform