Skip to content
Advertisement

2 columns one below another in sql

select cap2 as captain from data group by cap2
union all
select cap3 as captain from data group by cap3

I’m getting this error

ORA-12704: character set mismatch

can you please help me to fix this

Advertisement

Answer

See whether this helps.

I presume that this is your situation:

SQL> create table test
  2    (cap2 varchar2(10),
  3     cap3 nvarchar2(10));

Table created.

SQL> insert into test values ('A', 'B');

1 row created.

This is your current query:

SQL> select cap2 from test
  2  union
  3  select cap3 from test;
select cap2 from test
       *
ERROR at line 1:
ORA-12704: character set mismatch

This is what you might try to do – apply the to_char function to a nvarchar2 column:

SQL> select cap2 from test
  2  union
  3  select to_char(cap3) from test;

CAP2
----------------------------------------
A
B

SQL>
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement