Try to give me a solution

  • 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

  • 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 !!!**

  • 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

  • Can you post the link of the chanllenging query??

  • sorry i forgot it

    Regards

  • 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

  • Thx

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply