Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 433
  • Last Modified:

MySQL Max date

I am trying to get the max(date) from this query but it is not returning max
in the results the query returns this
2014-12-31 12:00:00  |  1008  | CO
but i know for a fact that this exists
2015-01-27 12:38:22  |  1008  | CO

Select MAX(UploadDate) as UploadDate,SerialNumber,ToolType FROM Inventory_SerializedAssets Where LocationID in(0) Group By SerialNumber);

Open in new window

0
r3nder
Asked:
r3nder
1 Solution
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Don't know about MySQL, but in SQL Server the ToolType column is listed in the SELECT clause and not in the GROUP BY clause, so either add it to GROUP BY or remove it from SELECT.
SELECT MAX(UploadDate) as UploadDate, SerialNumber, ToolType 
FROM Inventory_SerializedAssets 
WHERE LocationID in(0) 
GROUP BY SerialNumber, ToolType

Open in new window

Also, just to check the box, verify for us the LocationID of the row with the date of '2015-01-27 12:38:22' to make sure it equal zero, as if it doesn't the WHERE clause would remove that row from the return set.
0
 
r3nderAuthor Commented:
Thanks Jim
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Tackle projects and never again get stuck behind a technical roadblock.
Join Now