Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Syntax for simple (?) pivot with MODEL clause
dba_222_at_yahoo.com wrote:
> Dear Experts,
>
> I'm looking at the MODEL clause in 10G, and reading a number
> of articles on it.
>
> All I want to do is a simple pivot, with no hardcoding
> of potential values. Like what you can with Excel now.
>
> None of the articles I've read show any clear examples
> how to do this.
>
>
> For instance, looking at the SH schema:
>
> sh_at_dwhtest1>describe sales
> Name Null? Type
> ----------------------------------------------------- --------
> ---------------
> PROD_ID NOT NULL NUMBER
> CUST_ID NOT NULL NUMBER
> TIME_ID NOT NULL DATE
> CHANNEL_ID NOT NULL NUMBER
> PROMO_ID NOT NULL NUMBER
> QUANTITY_SOLD NOT NULL
> NUMBER(10,2)
> AMOUNT_SOLD NOT NULL
> NUMBER(10,2)
>
>
> Select channel_id, count(*)
>>From sales
>>From sales
>>From sales> order by 1
> Group by channel_id,
> promo_id
Then use DECODE and don't post to every usenet group you can spell.
You will find demo code you can use to learn it in Morgan's Library at www.psoug.org. Scroll down to DECODE. You can also do the same thing using CASE.
-- Daniel A. Morgan University of Washington damorgan_at_x.washington.edu (replace x with u to respond) Puget Sound Oracle Users Group www.psoug.orgReceived on Thu Aug 02 2007 - 13:21:46 CDT
![]() |
![]() |