September 15, 2005 at 1:36 am
This is the table containing single field
create table Temp(
c int)
insert into Temp values (1)
insert into Temp values (2)
insert into Temp values (3)
insert into Temp values (4)
insert into Temp values (1)
insert into Temp values (5)
output should be like this
col1 col2 col3
1 2 3
4 5 null
September 16, 2005 at 5:48 pm
why do you have a table with a "single field" - what purpose does it serve ?!
Besides - how do you expect to display the values of a single column in multiple ones ?! In any case, it's always preferable to handle display & formatting on client side!!!
It may help if you explain what exactly you're trying to do! As it stands, your question is very confusing (at least to me)!!!
**ASCII stupid question, get a stupid ANSI !!!**
September 18, 2005 at 11:35 pm
im not at all using this in my project..i saw this in the web site under a topic "challeging queires"..but i couldnt find the solution for this.....it can be queried using group by functions...but i couldnt make it..if u can find a solution let me know.the hint which i saw was "can be solved using group by function"
Regards
September 19, 2005 at 7:08 am
Can you post the link of the chanllenging query??
September 19, 2005 at 7:59 am
sorry i forgot it
Regards
September 30, 2005 at 7:05 am
With help from a friend, here is the answer
select max(case when (c-1)%3 = 0 then c else NULL end)
,max(case when (c-1)%3 = 1 then c else NULL end)
,max(case when (c-1)%3 = 2 then c else NULL end)
from #Temp
group by (c - 1) / 3
order by 1
September 30, 2005 at 7:10 am
Thx
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply