|
Posted by Hugo Kornelis on 10/08/44 11:35
On 23 Dec 2005 04:04:26 -0800, wgerrard@gmail.com wrote:
>Ah and one thing... I don't want to get flamed with "you shouldn't be
>doing this becasue it overturns X years of Y" .
Hi Will,
I won't flame you, but I will tell you, in all patience, that you should
not do this.
Like Erland, I have trouble understanding what EXACTLY it is that you
want. (I also have trouble understanding WHY you want it, but I just
agreed not to flame you with that <bg>).
But your query LOOKS like some sort of crosstab report. If I'm correct,
then you should indeed look into doing the formatting on the client. It
will be much faster.
If you really have to do it server-side, then check if the following
often-used format for crosstab queries helps you:
USE pubs
go
SELECT pub_id,
SUM(CASE WHEN type = 'business'
THEN ytd_sales ELSE 0 END) AS business,
SUM(CASE WHEN type = 'popular_comp'
THEN ytd_sales ELSE 0 END) AS popular_comp,
SUM(CASE WHEN type = 'psychology'
THEN ytd_sales ELSE 0 END) AS psychology,
SUM(CASE WHEN type = 'trad_cook'
THEN ytd_sales ELSE 0 END) AS trad_cook
FROM titles
GROUP BY pub_id
go
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
Navigation:
[Reply to this message]
|