Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: How do I get the record with the most current date Post Reply Post New Topic
Author Message
crystalgal
Groupie
Groupie
Avatar

Joined: 20 Feb 2009
Location: United States
Online Status: Offline
Posts: 66
Quote crystalgal Replybullet Topic: How do I get the record with the most current date
    Posted: 09 Nov 2012 at 1:10am
How do I get the record with the most current date for each person's ID?
I am doing this in sql.
right now I have
Select ID, testDate, Status1
from myTable a
where testDate = (select max(testDate) from myTable b
where a.ID = b.ID)

but this gives me the previous day date(when i ran today, it gave me yesterday's date)but in the databse the latest date is 11/1/2012
what am I missing?
TIA
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 10 Nov 2012 at 4:13am
how about trying:
Select a.ID, x.testDate, a.Status1
from myTable a
 cross apply (
  select max(testDate) as testDate
  from myTable b
  where a.ID = b.ID
 ) as x
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.