How do I get the column name as the 1st row of the result set.I tried below but getting the error as shown below
select 'First Name', 'Last Name', 'Middle Name', 'Term Number', 'BID', 'BTitle', 'SubB Name', 'LNum' from dual
UNION
select
pa.first_name as first_name,
pa.last_name as last_name,
pa.MIDDLE_INITIAL as middle_name,
bi.bi_num as num,
bi.b_id as bId,
b.name as b_title,
bi.sub_board_name as sub_b_name,
pa.L_NUMBER as lNum
from
M_INFO pa,
B_INV bi,
Blot b,
users u,
roles r
where
bi.assigned_to = u.bi_num(+)
and bi.bi_num = pa.bi_num(+)
and u.role_id = r.id(+)
and bi.b_id = b.id
and bi.delete_dt is null
and bi.delete_by is null
and bi.ARCHIVED_DT is null
and bi.b_id = '40' and bi.sub_b_name = 'TEST';
ORA-01790: expression must have same datatype as corresponding expression
01790. 00000 - "expression must have same datatype as corresponding expression"
*Cause:
*Action:
Error at Line: 1 Column: 50
I would recommend two changes to your query.
UNION
to UNION ALL
. This way your union will not look for duplicates between the two parts of the union.bi.bi_num
to TO_CHAR(bi.bi_num)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.