Hello, I am really bad explaining but I'll try...
I want to create a MYSQL query that returns the data based on the last entry in the table. I did it fine with the MAX function based on the date, but I need more advanced in terms of finding the last item entered by a specific product and return the last qty even if it's not the same date. This is a sample of the data I want as result:
Store| Product| Qty| Date
S1 | 1115 | 10| 12/30/09
S2 | 1115 | 20| 12/30/09
S3 | 1115 | 5| 12/29/09
S4 | 1115 | 15| 12/28/09
The query I have is this one, but it is only returning S1 and S2 because I have max on the date, but I want to return the most recent entry of x product by all stores:
Select
alias.storename,
inventory.Product_Code,
inventory.Inventory_Qty,
inventory.Date
From inventory Inner Join
Alias On inventory.Store = Alias.computername
Where inventory.Date = (Select Max(inventory.Date) From inventory)
Order By Alias.storename,
inventory.Product_Code
Any help is really appreciated