troubleshooting Question

order by max date desc

Avatar of phillystyle123
phillystyle123Flag for United States of America asked on
PHP
3 Comments1 Solution609 ViewsLast Modified:
hi  - this is what i'm trying to accomplish:

I want to select the rows with the most recent date for a given item_id.

The result should be:

inventory_date  inventory_count  item_id
2009-01-07       54               1
2008-12-31       65               2
2009-01-02       36               3

here's a pic of the table

http://www.microshell.com/wp-content/uploads/2009/01/optimize_max_min_inventory_table.jpg

the column names are wrong but will this logic work??
  $result = mysql_query('SELECT `http_referer`, COUNT(*) AS count, MAX(`date_requested`) AS last_request_date FROM `stats` WHERE `http_referer` IS NOT NULL GROUP BY `http_referer` ORDER BY MAX(`date_requested`) DESC');
ASKER CERTIFIED SOLUTION
me655321

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
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 3 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