Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Easy crosstab SELECT?
Message
From
14/05/2014 14:57:30
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Easy crosstab SELECT?
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2008
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01599978
Message ID:
01599978
Views:
62
I'm having to generate a report cursor with multiple child records displayed like part of the parent record. I thought there was an easy SELECT based trick to do this, but I'm not having much luck except by brute force. Can anyone help improve this?
SELECT Parent.TranID, Parent.Amount, Child.Tax_Amount as Tax1, 0 as Tax2, 0 as Tax3;
 FROM Parent LEFT OUTER JOIN Child on Parent.TranID = Child.TranID AND Child.Tax_Number = 1 INTO CURSOR t1
SELECT Parent.TranID, Parent.Amount, 0 as Tax1, Child.Tax_Amount as Tax2, 0 as Tax3;
 FROM Parent LEFT OUTER JOIN Child on Parent.TranID = Child.TranID AND Child.Tax_Number = 1 INTO CURSOR t2
SELECT Parent.TranID, Parent.Amount, 0 as Tax1, 0 as Tax2, Child.Tax_Amount as Tax3;
 FROM Parent LEFT OUTER JOIN Child on Parent.TranID = Child.TranID AND Child.Tax_Number = 1 INTO CURSOR t3

SELECT TranID, Amount, t1.Tax1, t2.Tax2, t3.Tax3;
 FROM t1;
 LEFT OUTER JOIN t2 ON t1.TranID = t2.TranID and t1.Amount = t2.Amount;
 LEFT OUTER JOIN t3 ON t1.TranID = t3.TranID and t1.Amount = t3.Amount 
Chris.
Next
Reply
Map
View

Click here to load this message in the networking platform