I'm having a challenge generating the following results in the picture below. I know how to write SQL code for Source, Max(DateTimeEnded) as "MaxDate" but don't know how to join the ElapsedTime to the MaxDate.
Your suggestions are appreciated.
Max based on Date/Time
-
- GoldLounger
- Posts: 2631
- Joined: 26 Jan 2010, 16:31
- Location: Southern California
Max based on Date/Time
You do not have the required permissions to view the files attached to this post.
Regards,
John
John
-
- Administrator
- Posts: 78594
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Max based on Date/Time
You can do this using a subquery:
Code: Select all
SELECT Source, DateTimeEnded, ElapsedTime
FROM [tablename]
WHERE DateTimeEnded =
(SELECT Max(T.DateTimeEnded)
FROM [tablename] AS T
WHERE T.Source = [tablename].Source)
Best wishes,
Hans
Hans
-
- GoldLounger
- Posts: 2631
- Joined: 26 Jan 2010, 16:31
- Location: Southern California