It's not a secret anymore!
The moose likes JDBC and Relational Databases and the fly likes DB2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "DB2" Watch "DB2" New topic


Keerthi Pandey

Joined: Feb 08, 2009
Posts: 7

I want the query for this:

I have a table called ABC where I have many columns including ABC_ID, ABC_BGN_DT, ABC_END_DT. Now this ABC_ID is a foreign key in my another table ABC_YER. This table contains values for that ABC_ID beginning from ABC_BGN_DT to ABC_END_DT(one year in each table).

Now I want to query this second table(ABC_YER) for any duplicates/not matching(ABC_BGN_DT to ABC_END_DT) for a particular ABC_ID.

Also I need to query the same table(ABC_YER) if the first row begin date is not matching with the ABC_BGN_DT of ABC for a particular ABC_ID.

I am a newbie. Please help ASAP.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32628

The trick with SQL queries is to write simpler queries and build up. For example,

Can you query for:
  • Do a join between tables 1 and 2
  • Restrict by date
  • Identify duplicates

  • [OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
    Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
    I agree. Here's the link:
    subject: DB2
    It's not a secret anymore!