Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SQL Query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Bhavan JS
Warnings : 1

New User


Joined: 30 Nov 2007
Posts: 10
Location: Bangalore

PostPosted: Fri Dec 14, 2007 6:05 pm    Post subject: SQL Query
Reply with quote

Hi,

Below are my 2 tables;

Table:A
NOTE_ID
REP_ID

Table:B
NOTE_ID
M_TMSTMP

I want to take all the REP_IDs from Table A which are added today.

Here is the query I' am using for this;

SELECT REP_ID FROM Table:A WHERE NOTE_ID IN
(
SELECT NOTE_ID FROM Table:B WHERE M_TMSTMP = CURRENT_DATE
)

But from the result set of the above query (Lets say REP_IDs 1,2,3), I want only the REP_IDs which are already not availabe in Table:A. (If Table:A containts REP_IDs 1,2,4,5,6, I want to take only 3 since 1 and 2 are already present in Table:A. Simply, I want REP_IDs from Table:A which are added today and already not available in Table:A.

I have to use only SQL query with Sub Queries or Joins.

Thanks in advance,
Bhavan.
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10274
Location: italy

PostPosted: Fri Dec 14, 2007 6:28 pm    Post subject: Reply to: SQL Query
Reply with quote

search the forums...
the question was already asked and answered :-)
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10274
Location: italy

PostPosted: Fri Dec 14, 2007 6:32 pm    Post subject: Reply to: SQL Query
Reply with quote

I just searched the forums for You...

http://www.ibmmainframes.com/viewtopic.php?t=26451

same homework uh....
Back to top
View user's profile Send private message
Bhavan JS
Warnings : 1

New User


Joined: 30 Nov 2007
Posts: 10
Location: Bangalore

PostPosted: Mon Dec 17, 2007 9:05 pm    Post subject: Reply to: SQL Query
Reply with quote

Thanks Enrico. Sorry for late response.

Bhavan.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us