DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Transpose query results ?

  1. #1
    Join Date
    Feb 2000
    Location
    Singapore
    Posts
    1,758
    Is there any way we can transpose the query results in SQL*Plus. (i.e. change rows into columns and vice versa)

    Appreciate all help.

    Regards,
    Sanjay

  2. #2
    Join Date
    Mar 2001
    Posts
    32
    Hi

    You can always make use of decode built-in function
    for this kind of work.

    For eg:

    Table1-----Gender[Column]
    --Male-- Rows
    --Female--Rows
    To get the value of male & female we can use following methods

    1. select gender,count(*) from table1
    group by gender;

    The result would be of

    Male 200
    Female 190

    2. select count(decode(gender,"Male",gender)) "Male",
    count(decode(gender,"FeMale",gender)) "FeMale"
    from table1

    The result would be of
    Male Female

    200 190

    I hope this would clear your doubt and power of
    decode.Plz get back if you still feel unconfortable with
    this...

    Love whatever you do.....






Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width