Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to select multiple constant values with a select statement along with other columns

NikJunejaJan 6 2016 — edited Jan 6 2016

Hi All,

I have a small query realted to selecting values from a table.

create table employee (eid number, ename varchar2(20));

insert into employee values (1,'Nik');

insert into employee values (2,'Prashant');

commit;


Now I have a small list say A, b, C , i want to select this list along with all rows like

with test1 as(

          select eid, ename from employee

          )

          select eid,ename, 'A' col1 from test1

          UNION ALL

          select eid,ename, 'B' col1 from test1

          UNION ALL

          select eid,ename, 'C' col1 from test1

but the issue with this is that in production my employee table has millions of records and this scans the employee table thrice (or the number of constant values)

Is ther any other way to acheive this.

Thanks,

Nik

This post has been answered by Paulzip on Jan 6 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 3 2016
Added on Jan 6 2016
1 comment
5,404 views