Re: Is this query possible?
Date: 1996/07/12
Message-ID: <4s5pbh$5g0_at_news.aimnet.com>#1/1
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
This is called 'pivoting a table'
Look it up in the Sybase FAQ
(http://reality.sgi.com/employees/pablo_corp/Sybase_FAQ/ )
or by an excellent book "Optimizing Transact-SQL: Advanced Programming
Technique". It's published by "SQL Forum Press"
(800)943 9300
Received on Fri Jul 12 1996 - 00:00:00 CEST