Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL - How Do I Do This?
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00681371
Message ID:
00681750
Vues:
17
It's easy to fix by adding to the second select
...
    AND EXISTS ( SELECT * ;
			FROM lineitem t3 ;
			WHERE RecType = "A" ;
				AND t3.ParentId = t1.ParentId ;
				AND t3.LineId = t1.LineId ) ;
...
>Applause
>
>But, Be aware that if an item is not active you would still show an inactive for that item...
>
>>The first select will pull all active records. The second select will pull all inactive records with MAX RevNum value.
SELECT * ;
>>  FROM lineitem  ;
>>  WHERE RecType = "A" ;
>>UNION ALL ;	
>>SELECT * ;
>>  FROM lineitem t1 ;
>>  WHERE RevNum IN ( SELECT MAX(RevNum) ;
>>			FROM lineitem t2 ;
>>			WHERE RecType = "I" ;
>>				AND t2.ParentId = t1.ParentId ;
>>				AND t2.LineId = t1.LineId ) ;
>>ORDER BY 2, 3, 4 ;
>>INTO CURSOR crsResult
>>
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform