Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Getting the last date for in history table

Posted on 2008-06-24
4
Medium Priority
?
239 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
[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
4 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 400 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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 …
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

688 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