Solved

MySQL Max date

Posted on 2015-01-27
2
405 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

821 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