Pages

19 June, 2023

Get max and min value's unique id while using group by

I have a table with columns: unique_id, product, root_location, price with more than 50 million records I want the result to be product, min_price, min_price_unique_id, max_price, max_price_unique_id My query: select product , min(price) as min_price , max(price) as max_price from mytable group by product How to get the unique id's of min and max price?

No comments:

Post a Comment

Thanks