我有一张桌子student(name_std,age_std,address_std)
。当我写查询
select * from Student
显示
name_std age_std address_std
Deepak 22 London
Anjali 16 Srilanka
我的要求是当我查询select * from Student
时,它应该给我输出
name_std age_std address_std
**Name Age Address** <<alias row>>
Deepak 22 London
Anjali 16 Srilanka
请建议我一些解决方案
答案 0 :(得分:1)
尝试UNION
,如下所示:
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
答案 1 :(得分:0)
我认为您可以对每列使用alias
来实现所需的输出。
SELECT name_std as Name age_std as Age address_std as Address
FROM Student
答案 2 :(得分:0)
您必须取消*
并使用列名和别名
SELECT name_Std "Name", age_std "Age", address_std "Address"
FROM student
答案 3 :(得分:0)
假设age_std为数字 -
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;