sql query with where condition [message #587077] |
Wed, 12 June 2013 09:11  |
 |
satyam_mitm@yahoo.com
Messages: 1 Registered: June 2013 Location: India
|
Junior Member |
|
|
Hi All,
I have EMPLOYEE table that have 3 records with EMP_ID 1, 2, 3.
Now I want to run below query
select emp_id from employee where emp_id in (1, 2, 3, 4, 5);
It will return only 3 records but i want those records also which is not available in employee table.
Is this possible wihtout using another table or creating another table.
Actually I don't have enough priveleges to create table.
& want output like below
EMP_ID
1
2
3
4 Not Found
5 Not Found
Here emp_id 4, 5 is not available in employee table, but query should return those value also with comments like "Not Found"
|
|
|
|
Re: sql query with where condition [message #587080 is a reply to message #587077] |
Wed, 12 June 2013 09:16   |
 |
Michel Cadot
Messages: 68765 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
SQL> select nvl(to_char(e.empno), column_value||' Not found') empno
2 from table(sys.odcinumberlist(7369,7370,7566,7555)) l
3 left outer join
4 emp e
5 on e.empno = l.column_value
6 order by 1
7 /
EMPNO
--------------------------------------------------
7369
7370 Not found
7555 Not found
7566
4 rows selected.
Regards
Michel
[Updated on: Wed, 12 June 2013 09:17] Report message to a moderator
|
|
|
|
|
|
Re: sql query with where condition [message #587126 is a reply to message #587124] |
Wed, 12 June 2013 11:01  |
 |
Michel Cadot
Messages: 68765 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Oh! I didn't understand the question.
Yes, the type "odcinumberlist" is accessible to anyone but there is no synonym on it so you have to prefix it by "SYS." as I did.
Regards
Michel
|
|
|