Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MySQL Max date

Posted on 2015-01-27
2
Medium Priority
?
432 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 2000 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

705 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