| Vaibhav |
Posted: Apr 22, 2008 02:05:43 AM |
Total Post: 11
Joined: Jan, 2008
|
Hello Dear,
I create a table-
create table emp(
name varchar2(10),
salary number(5))
insert into emp values('A',10000)
insert into emp values('B',9000)
insert into emp values('C',5000)
the result is
----------------
name salary
A 10000
B 9000
C 5000
Now I want to display the result as -
Name A B C
Salary 10000 9000 5000
Kindly help !!
Looking forward for your response.
|
|
|
GOPU |
| Posted: Apr 22, 2008 02:46:33 AM | |
|
Total Post: 272
Joined: Apr, 2008
|
HI,
it is possible butyou have to use some plsql methods to display like that.
regards
Gopu
|
|
|
|
|
Vaibhav |
| Posted: Apr 22, 2008 04:09:35 AM | |
|
Total Post: 11
Joined: Jan, 2008
|
Can Anyone tell me what Pl/Sql methods I have to use.
Thanks in advance !!
|
|
|
|
|
Murtuja |
| Posted: Apr 22, 2008 04:27:47 AM | |
|
Total Post: 843
Joined: Jan, 2006
|
Hi,
http://www.orafaq.com/wiki/SQL_FAQ#How_does_one_code_a_matrix.2Fcrosstab.2Fpivot_report_in_SQL.3F
|
|
|
|
|
gps |
| Posted: Apr 22, 2008 06:07:20 AM | |
|
Total Post: 38
Joined: May, 2006
|
Try this PL/SQL Code for desired result:
set serveroutput on
declare
cursor c1 is select name, sal from emp
order by name;
one varchar2(4000):='Name ';
two varchar2(4000):='Salary ';
begin
for i in c1 loop
one:=one||' '||i.name;
two:=two||' '||i.sal;
end loop;
dbms_output.put_line(one);
dbms_output.put_line(two);
end;
/
Gurwinder
|
|
|
|
|
GOPU |
| Posted: Apr 22, 2008 06:24:03 AM | |
|
Total Post: 272
Joined: Apr, 2008
|
Hi,
Very good answer man... :).
I run that query and i got the answer...
thanks for sharing that
Gopu
SQL> declare
2 cursor c1 is select name, salary from emp order by name;
3 one varchar2(4000):='Name ';
4 two varchar2(4000):='Salary ';
5 begin
6 for i in c1 loop
7 one:=one||' '||i.name;
8 two:=two||' '||i.salary;
9 end loop;
10 dbms_output.put_line(one);
11 dbms_output.put_line(two);
12 end;
13 /
Name A B C
Salary 10000 9000 5000
PL/SQL procedure successfully completed.
|
|
|
|
|
Vaibhav |
| Posted: Apr 22, 2008 11:12:10 PM | |
|
Total Post: 11
Joined: Jan, 2008
|
|
|
|
|
| Time Zone: EDT |
Send this thread to your friend |