Solved

Getting the last date for in history table

Posted on 2008-06-24
4
225 Views
Last Modified: 2010-05-18
So i have a history table that keeps track of all the approvals on a request. I need to find out who did the last approval for the record. so for instance

Item                                       Who Approved      Date
1                                            person X                 06/11/08
1                                            person Y                  06/08/08
1                                           person b                   06/05/08

2                                            person r                 06/11/08
2                                            person g                  06/08/08
2                                            person b                   06/05/08

so i would want my result set to be
1                                            person X                 06/11/08
2                                            person r                 06/11/08

i tried to group by the ID and getting the max date but then i lose who did the last approval
0
Comment
Question by:Steege
  • 3
4 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 100 total points
ID: 21858205
Hello Steege,

SELECT a.* FROM urTable a
inner join (SELECT Item, MAX(Date) maxDate from urTable GROUP BY Item ) b
ON a.Item = b.MaxDate

GOD BLESS,

Aneesh R.
0
 

Author Comment

by:Steege
ID: 21858346
i am assuming the on statement should be a.item = b.item
0
 

Author Comment

by:Steege
ID: 21858353
sorry a.date = b.maxdate
0
 

Author Closing Comment

by:Steege
ID: 31470289
thanks for the help!!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

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…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

930 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

11 Experts available now in Live!

Get 1:1 Help Now