Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Slow view needs optimization help
Jon Davis wrote:
> This might be too much hassle for most of you but someone might be up for a
> good challenge. I need to figure out how to optimize this query (at bottom
> of this post) for Oracle 9i.
I can't possibly work on that enormous query, but have you considered using this common approach to "pivot" queries instead?
SELECT A.ACCOUNTID, ...
SUM( CASE WHEN A.MO = 1 THEN A.QUANTITY END) JAN_QTY, SUM( CASE WHEN A.MO = 2 THEN A.QUANTITY END) FEB_QTY, ... SUM(A.QUANTITY) YR_QTY