-
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
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|