Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Optimize this SQL
Message
 
À
28/02/2007 11:53:47
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01199356
Message ID:
01199650
Vues:
16
>Hi Naomi,
>
>It work's, sorry i try to group with cNomFor, the working one, now try with real data.
>
>
>select c_cod_art,min(cNomFor) as cNomFor,
>       SUM(CASE n_terceiro WHEN 1 THEN n_quant ELSE 0 END) as QtCli,
>       SUM(CASE n_terceiro WHEN 2 THEN n_quant ELSE 0 END) as QtFor
>from  #mov_enc_plano
>group by c_cod_art
>order by c_cod_art
>
Joao,
With that approach you got SOME cNomFor, what you want from that data:
c_cod_art         cNomFor          n_terceiro         n_quant
--------------------------------------------------------------
TEST1            NOM1                 1                  25 
TEST1            NOM2                 2                  30
TEST1            NOM3                 2                  31
TEST1            NOM1                 1                  21

TEST2            NOM1                 1                  26 
TEST2            NOM2                 2                  37
TEST2            NOM3                 2                  20
TEST2            NOM1                 1                  28
With this SELECT you will have that result:
c_cod_art         cNomFor          QtCli         QtFor
------------------------------------------------------
TEST1             NOM1              46            61
TEST2             NOM1              54            57
Is that what you want?
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform