I have the following query:
SELECT * FROM quotes
INNER JOIN quotes_panels ON quotes.wp_user_id = quotes_panels.ID
WHERE quotes.created >= '$startDate'
AND quotes.created <= '$endDate' AND quotes.wp_user_id != '0'
This query can produce multiple rows from the same user (quotes.wp_user_id) but I only want to show the row which has the biggest roof area (quotes.roofarea).
However when I added GROUP BY quotes.wp_user_id it automatically takes the lowest quotes.ID row rather than the row with the biggest quotes.roofarea. When adding ORDER BY quotes.roofarea DESC to the end of the query it ordered the entire results not just the results of the “GROUP BY”.
Can anyone assist with getting the desired results for the query?
Thanks
Try this
Check Now