Skip to content
Advertisement

Oracle sql adding custom column name as 1st row of the resultSet

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

Advertisement

Answer

I would recommend two changes to your query.

  1. Change UNION to UNION ALL. This way your union will not look for duplicates between the two parts of the union.
  2. Since the first part of your union is all strings, the second part of your union needs to return all strings as well. Any columns in the second part of your union that are numbers need to be converted to a string. Example: change bi.bi_num to TO_CHAR(bi.bi_num)
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement