Re: SQL Query Question



SELECT Date,
SUM(CASE WHEN ProductTypeID=1 THEN Quantity ELSE 0 END) AS Type1,
SUM(CASE WHEN ProductTypeID=2 THEN Quantity ELSE 0 END) AS Type2,
SUM(CASE WHEN ProductTypeID=3 THEN Quantity ELSE 0 END) AS Type3
FROM TableA
GROUP BY Date

.



Relevant Pages

  • Lookup and paste
    ... type1 old 123 ... type3 new 789 ... I need to match the two criteria ie type2 and old to get 456. ... Then match type2 and B in the same worksheet as well as yesterdays date ...
    (microsoft.public.excel.programming)
  • Re: Remove repeat section headers
    ... but I need to have a header for each and mess with the ...
    (microsoft.public.access.reports)
  • Re: Remove repeat section headers
    ... actually want it to group within the types but rather group the entire type1 ... but I need to have a header for each and mess with the ...
    (microsoft.public.access.reports)
  • Re: extracting a sample of each condition
    ... select plan, type1, type2, type3 from table ...
    (comp.databases.oracle.misc)
  • Re: Remove repeat section headers
    ... but I need to have a header for each and mess with the ...
    (microsoft.public.access.reports)