wood burning stoves 2.0*
The moose likes JDBC 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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
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
internet detective

Joined: May 26, 2003
Posts: 29237

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

  • [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
    Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
    I agree. Here's the link: http://aspose.com/file-tools
    subject: DB2
    Similar Threads
    populating drop down list from database table
    populating drop down list from database table
    No results in query using JDBC, works in Db
    Updating duplicate rows
    two queries combined together into a single one