LeonelSanchezJr
Programmer
The following query does not give me a distinct DocNum
when the dates are all the same; plus I need to add the Time field (currently commented out) to my MAX function.
NOTE: The dDate field is a true DATETIME field, but the
cTime field is a character field such as 09:46:05.
Insert Into #Tmp3
Select Distinct A.cDocNum,
A.cStat
From Stat A
Inner Join (Select Distinct Stat.cDocNum,
Max(Stat.dDate + Stat.cTime) As MaxDateTime
From Stat Group By Stat.cDocNum) As B
On A.cDocNum = B.cDocNum
And A.dDate = B.MaxDateTime
when the dates are all the same; plus I need to add the Time field (currently commented out) to my MAX function.
NOTE: The dDate field is a true DATETIME field, but the
cTime field is a character field such as 09:46:05.
Insert Into #Tmp3
Select Distinct A.cDocNum,
A.cStat
From Stat A
Inner Join (Select Distinct Stat.cDocNum,
Max(Stat.dDate + Stat.cTime) As MaxDateTime
From Stat Group By Stat.cDocNum) As B
On A.cDocNum = B.cDocNum
And A.dDate = B.MaxDateTime