This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "DB2" Watch "DB2" New topic
Author

DB2

Keerthi Pandey
Greenhorn

Joined: Feb 08, 2009
Posts: 7
Hi,

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
Marshal

Joined: May 26, 2003
Posts: 30068
    
149

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
    two queries combined together into a single one
    No results in query using JDBC, works in Db
    populating drop down list from database table
    Updating duplicate rows
    populating drop down list from database table