Re: Is this query possible?

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: 1996/07/11
Message-ID: <31e44d58.4688581_at_dcsun4>#1/1


you cross posted to various database groups but if you are using Oracle you can:

select weekNo, ID,

       sum(decode(dayNo,1,total,0)) Mon, 
       sum(decode(dayNo,2,total,0)) Tue, 
       sum(decode(dayNo,3,total,0)) Wed, 
       sum(decode(dayNo,4,total,0)) Thr, 
       sum(decode(dayNo,5,total,0)) Fri

from T
group by weekNo, Id
/

to get that.

On 10 Jul 1996 19:11:58 -0500, mskc_at_io.com (Casey Claiborne) wrote:

>
>Hello,
> I have rows that are similar to the following:
>
>
>YearNo WeekNo DayNo ID Total
>------ ------ ----- --- -----
>1996 1 1 7 $35.00
>1996 1 2 7 $65.00
>1996 1 3 7 $25.00
>1996 1 4 7 $12.00
>1996 1 1 10 $35.00
>1996 1 2 10 $65.00
>1996 1 3 10 $25.00
>1996 1 4 10 $12.00
>1996 1 1 12 $35.00
>1996 1 2 12 $65.00
>1996 1 3 12 $25.00
>1996 1 4 12 $12.00
>
>I need to get a result of something like ...
>
>WeekNo ID Mon Tue Wed Thur Fri.
>1 7 $35 $65 $25 $12 0
>1 10 $35 $65 $25 $12 0
>1 12 $35 $65 $25 $12 0
>
>
>How can I do this? Any help hints or advice would be *greatly*
>appreciated :) Sorry about the length of this post, I just
>wanted to be clear -
>
>TIA
>
>

Thomas Kyte
Oracle Government
tkyte_at_us.oracle.com                          

http://govt.us.oracle.com -- Check out our web site! Brand new, uses Oracle Web Server and Database


statements and opinions are mine and do not necessarily reflect the opinions of Oracle Corporation Received on Thu Jul 11 1996 - 00:00:00 CEST

Original text of this message