Home » SQL & PL/SQL » SQL & PL/SQL » LEFT JOIN _last_ of matchin entries
LEFT JOIN _last_ of matchin entries [message #446741] Wed, 10 March 2010 04:20 Go to next message
Messages: 1
Registered: March 2010
Junior Member

I have this table:


I also have this table


The entries in the second table overlap, for any given time moment there can be more than one matching entry.

I need to join second table to the first one, but take only the last of matching records.

If the entries wouldnt overlap, I could do a left join on StartDate <= Date AND EndDate >= Date AND TypeID=TypeID. But in this case, this would duplicate records.

So how do I do this? Sad
Re: LEFT JOIN _last_ of matchin entries [message #446743 is a reply to message #446741] Wed, 10 March 2010 04:24 Go to previous messageGo to next message
Messages: 941
Registered: December 2008
Location: Surat, The Diamond City
Senior Member
Provide properly working test case with original and expected output.

Re: LEFT JOIN _last_ of matchin entries [message #446745 is a reply to message #446741] Wed, 10 March 2010 04:24 Go to previous message
Michel Cadot
Messages: 63911
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
If you post a working Test case: create table and insert statements along with the result you want with these data then we will work with your table and data.

Before please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version with 4 decimals.

Previous Topic: CURSOR in ORACLE
Next Topic: Which query would execute quickest
Goto Forum:

Current Time: Fri Oct 21 17:37:17 CDT 2016

Total time taken to generate the page: 0.20069 seconds