Reputation: 41
I have a table student(name_std,age_std,address_std)
. When i write query
select * from Student
it displays
name_std age_std address_std
Deepak 22 London
Anjali 16 Srilanka
My requirement is that when I query select * from Student
,It should give me output like
name_std age_std address_std
**Name Age Address** <<alias row>>
Deepak 22 London
Anjali 16 Srilanka
please suggest me some solution
Upvotes: 0
Views: 3192
Reputation: 4538
Assuming age_std as number -
SELECT 'Name' name_std,
'Age' age_std,
'Address' address_std
FROM dual
UNION ALL
SELECT name_std,
To_char(age_std),
address_std
FROM student;
Upvotes: 0
Reputation: 6543
Try UNION
like below :
SELECT 'Name' as name_std,'Age' as age_std, 'Address' as address_std FROM dual
UNION
SELECT name_std,to_char(age_std),address_std FROM Student
Upvotes: 1
Reputation: 3074
You will have to do away with *
and use the column names and aliases
SELECT name_Std "Name", age_std "Age", address_std "Address"
FROM student
Upvotes: 0
Reputation: 23480
I think you can just use alias
to each column to achieve your desired output.
SELECT name_std as Name age_std as Age address_std as Address
FROM Student
Upvotes: 0