Solved

Query to get the latest modified records

Posted on 2008-10-24
3
716 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 60

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

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

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

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

707 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