Afficher un message
Vieux 24/03/2008, 15h29   #2
--CELKO--
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Doing Summation on multiple criterias on the same column in asingle query

You need to stop using reserved words (MONTH, INDICATOR, etc) for
column names:

SELECT sales_month,
SUM(CASE WHEN flag = 0 THEN vague_value ELSE NULL END) AS
foo_tot,
SUM(CASE WHEN flag = 1 THEN vague_value ELSE NULL END) AS
bar_tot,
FROM Foobar;

It is also a bad idea to use proprietary BIT data types to fake
assembly language style programming. SQL is a predicate language;
that is, we discover a fact with a predicate rather than set a flag.
  Réponse avec citation
 
Page generated in 0,05387 seconds with 9 queries