View previous topic :: View next topic
|
Author |
Message |
sivatechdrive
Active User
Joined: 17 Oct 2004 Posts: 191 Location: hyderabad
|
|
|
|
Hi All,
I am in requirement of query as below, can some one help me.
My table say EMP has rows as below
Code: |
EMPNO EMPNAME
100 A
200 B
300 C |
If i write a select as below
Code: |
SELECT EMPNO from EMP where EMPNO in (100,250,300,500) |
in general the output is
But i want the output as below
Code: |
EMPNO
100
250 Not Found in table
300
500 Not Found in table |
Thanks ..prasad
Edited: Please use BBcode when You post some code, that's rather readable...Anuj |
|
Back to top |
|
|
nabarundas
New User
Joined: 21 Jun 2007 Posts: 28 Location: pune
|
|
|
|
Hi sivatechdrive,
I can suggest you one query which acts in the reverse way
Code: |
select empid,
case when empid in ('1','2') then 'found in the list'
else 'not found in the list'
end as status
from nabarun.tablea
|
You can have a look at it and see whether it will be helpful or not.
But I am not exactly sure whether only query can bring your desired output. |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
nabarundas,
Did you execute your query? How can you display '250' and '500' which are not present in table? |
|
Back to top |
|
|
nabarundas
New User
Joined: 21 Jun 2007 Posts: 28 Location: pune
|
|
|
|
Hi ksk,
By the query we are not displaying '250' and '500'.
In the first line itself I have writen that it acts in the reverse way(display the EMPNO from the Table not from the list)
And the query was not the solution of the problem(I already mention that). |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
iS the IN clause values always constant ? |
|
Back to top |
|
|
|