I don't understand what I need to do to get a value from a different column of a joined table when using MAX().
SELECT layout.NAME,layout.ID,MAX(inventory_reports.CLOSETIME)
FROM layout
LEFT JOIN inventory_reports ON layout.ID = inventory_reports.POSID
WHERE layout.INVENTORY = 1 AND layout.AVAILABLE = 1
GROUP BY layout.ID
ORDER BY layout.NAME
The table inventory_reports
also contains a column called CLOSER
. How can I get that value for the row matching the MAX(inventory_reports.CLOSETIME)
?
I tried playing around with joining on subqueries, but all my attempts so far have given me incorrect results.