Solved

Query to get the latest modified records

Posted on 2008-10-24
3
704 Views
Last Modified: 2012-08-13
My table A contains records with multiple entries of same ID (Attached Table A structure) also it contains modified date column as well.

Now i require a query to get only the latest modified records in my result set.(Attached the expected result as well). Please help
TableExpectedresult.xls
0
Comment
Question by:tks_g100
3 Comments
 
LVL 9

Accepted Solution

by:
jamesgu earned 200 total points
ID: 22798961
select * from Table_A a
where not exists ( select 1 from Table_A b where a.asset_id = b.asset_id and b.modified_date > a.modified_date)

0
 
LVL 59

Assisted Solution

by:Kevin Cross
Kevin Cross earned 100 total points
ID: 22799136
SELECT *
FROM Table_A a
INNER JOIN (SELECT asset_id, max(modified_date) AS max_modified_date FROM Table_A GROUP BY asset_id) b
ON a.asset_id = b.asset_id AND a.modified_date = b.max_modified_date
0
 

Author Closing Comment

by:tks_g100
ID: 31509770
Thanks for the query. Both yielded the results
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now