Solved

MySQL Max date

Posted on 2015-01-27
2
391 Views
Last Modified: 2015-01-27
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
Comment
Question by:r3nder
2 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 40573431
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
 
LVL 6

Author Closing Comment

by:r3nder
ID: 40573495
Thanks Jim
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now