July 23, 2010 at 11:27 am
Hello Everyone
I am not on dope, nor do I drink. I just cannot figure out how to write this query to give me the resultset that I would like. It is simple, but I am missing something from the 101 class of T-SQL.
There is a system table in the MSDB database named sysdtspackagelog. It has a name and a logdate column. The name will be duplicate, and the logdate is a simple log table. Basically keep track of when each DTS package was fired off. The name column is an ordinary varchar, and the logdate is datetime.
I would like to write a query that works, to select the Name and the MAX logdate for each name.
So the results would almost be like a DISTINCT on the Name and the MAX(LogDate). But I am missing something easy. I cannot get this to work correctly. Should I JOIN the table on itself?
Thanks in advance for all your help.
Maybe it is time for me to go home and step away from this.
Andrew SQLDBA
July 23, 2010 at 11:33 am
select name, MAX(logdate) from sysdtspackagelog
group by name
July 23, 2010 at 11:45 am
Thank You
I thought that I had tried it that way, and it had a syntax error. I have tried so many things, my mind is all mush now.
That worked perfectly
Thanks you
Andrew SQLDBA
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply