Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Optimize this SQL
Message
 
 
To
27/02/2007 17:13:39
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01199356
Message ID:
01199363
Views:
13
It would create 2 lines if one of the columns in GROUP BY is different for n_terceiro=1 and n_terceiro=2.

>With this SQL statement i can SUM all qtCli and all qtFor for all cod_art, but it creates two lines one for QtCli and other for QtFor, any chance to join them in only one line
>
>
>	select c_codigo as c_cod_ter, cNomFor,c_cod_art,c_desc_art,
>		c_grupos,n_stk_real,
>		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_codigo,c_cod_art, cNomFor,c_desc_art,c_grupos,n_stk_real
>	order by c_cod_art
>
>
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform