Hello everyone im looking for solution tu group by just Store_ID i need to found best employee regarding revenu for each store I know taht in this case i can use LIMIT(2) but i would like to do it in correct way
Expected Result
CodePudding user response:
Use DISTINCT ON
:
SELECT DISTINCT ON (store_id) store_id, full_name, revenue
FROM yourTable
ORDER BY store_id, revenue DESC;