Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Easy crosstab SELECT?
Message
De
14/05/2014 14:57:30
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Easy crosstab SELECT?
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2008
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01599978
Message ID:
01599978
Vues:
63
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.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform