Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best SQL statement
Message
De
09/09/2007 07:39:20
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
09/09/2007 02:01:06
Reza Meamar
Homa Programming Group
Shiraz, Iran
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 7 SP1
Divers
Thread ID:
01253272
Message ID:
01253281
Vues:
20
>I have a table with below record:
>
>FldCode   FldTrue   FldSum
>  21         T      10000
>  21         T      20000
>  22         T      30000
>  23         F      40000
>  24         F      50000
>
>I want to write a SQL statment that return below result:
>
>FldCode   FldTrue   FldSum
>             T      30000
>             T      30000
>             F      90000
>
>( I want Sum of similar FldCode and so Sum of records that FldTrue = .F. )
>
>Thanks

Viv got close :)

SELECT fldcode, SUM(fldsum) FROM table GROUP BY fldcode WHERE fldtrue ;
UNION ;
SELECT 00,SUM(fldsum) FROM table WHERE !fldtrue

The 00 in the UNION SELECT has to be the same type and size as fldcode.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform