IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

My table say EMP has rows as below


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sivatechdrive

Active User


Joined: 17 Oct 2004
Posts: 191
Location: hyderabad

PostPosted: Fri Oct 31, 2008 12:11 pm
Reply with quote

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
Code:
EMPNO
100
300

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
View user's profile Send private message
nabarundas

New User


Joined: 21 Jun 2007
Posts: 28
Location: pune

PostPosted: Tue Nov 04, 2008 12:37 pm
Reply with quote

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
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Tue Nov 04, 2008 2:18 pm
Reply with quote

nabarundas,

Did you execute your query? How can you display '250' and '500' which are not present in table?
Back to top
View user's profile Send private message
nabarundas

New User


Joined: 21 Jun 2007
Posts: 28
Location: pune

PostPosted: Tue Nov 04, 2008 2:28 pm
Reply with quote

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
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Tue Nov 04, 2008 9:41 pm
Reply with quote

iS the IN clause values always constant ?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top