Re: Oracle Query Help

From: MarkyG <markg_at_mymail.tm>
Date: 20 Jun 2001 02:09:08 -0700
Message-ID: <ab87195e.0106200109.70da05fb_at_posting.google.com>


I havent got the tables to prove it but try....

select
 date,

 decode(product,A,quantity,0) as producta,
 decode(product,b,quantity,0) as productb,
 decode(product,c,quantity,0) as productc
from person
group by date;

M

deaduser_at_hotmail.com (Jeffrey Ellin) wrote in message news:<e8a45386.0106191721.2d2c3e0e_at_posting.google.com>...
> Hi,
> I am trying to create a SQL query to create a report off of a table
> that isn't really in
> the form I want. Ideally this would be in the form of a view that I
> could select of a
> particular personid.
>
> Person.
>
> Personid Date Product Quantity
> 1 1/3/94 A 4
> 1 1/5/94 A 3
> 1 1/3/94 B 5
> 1 1/5/94 C 8
>
>
>
> I want a report that looks something for this.
>
>
> Date ProductA ProductB ProductC
> 1/3/94 4 5 0
> 1/5/95 3 0 8
>
> I tried something like
> select personid,
> decode(product,A,quantity,0) as producta,
> decode(product,b,quantity,0) as productb,
> decode(product,c,quantity,0) as productc
> from person
>
> but I get something more like this
>
> Date ProductA ProductB ProductC
> 1/3/94 4 0 0
> 1/5/95 3 0 0
> 1/3/94 0 5 0
> 1/5/95 0 0 8
>
>
> Not quite right.
Received on Wed Jun 20 2001 - 11:09:08 CEST

Original text of this message