Re: Displaying columns from 2 independant tables
From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 12/10/04
- Previous message: Wes: "Displaying columns from 2 independant tables"
- In reply to: Wes: "Displaying columns from 2 independant tables"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 10 Dec 2004 20:48:32 +0100
On Fri, 10 Dec 2004 09:55:41 -0800, Wes wrote:
>I have a table as follows:
(snip)
>I would like to sum the quantity of each code and staus
>and display in tabular format as follows
(snip)
Hi Wes,
If you can do the formatting at the client side (where it ought to be
done), use this:
SELECT Code, Status, SUM (Quantity)
FROM MyTable
GROUP BY Code, Status
If you must do the formatting at the server side:
SELECT Code,
SUM (CASE WHEN Status = 'Dispatched' THEN Quantity ELSE 0 END) AS
"Qty Dispatched",
SUM (CASE WHEN Status = 'Awaiting Dispatch' THEN Quantity ELSE 0
END) AS "Qty Awaiting Dispatch"
FROM MyTable
GROUP BY Code
(both queries untested)
Best, Hugo
-- (Remove _NO_ and _SPAM_ to get my e-mail address)
- Previous message: Wes: "Displaying columns from 2 independant tables"
- In reply to: Wes: "Displaying columns from 2 independant tables"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|