troubleshooting Question

How to use MAX() and Group to gather query results?

Avatar of evibesmusic
evibesmusicFlag for United States of America asked on
8 Comments1 Solution226 ViewsLast Modified:

I am struggling to find the correct syntax for my query.

For simplicity purposes, let's say my db table has 5 columns: id, Name, Date, Year, Month

I need to identify the last record in the db based on the MAX(Date) where the report Name='Activity Report'.  What further complicates this query is the fact that I need to be able to grab all of the information from the DB row found so that I can print it to the screen later.

This is what I have so far:

SELECT MAX(Date) as most_recent, id, Name, Date, Year, Month FROM reports WHERE Name='Activity Report' ORDER BY Name ASC

I know this is not correct but, all of the examples I have seen just confuse me even more.

Can anyone assist?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros