I have a table called 'product' with columns - product_name, sale_price, sale_date
I want to get min(sale_price) and max(sale_price) and the dates in which sales of min and max prices happened.
I have my query like this:
SELECT sale_price, sale_date FROM product WHERE (sale_price) IN (
SELECT
min(sale_price)
FROM product
WHERE product_name = 'PHONE'
) AND product_name = 'PHONE'
UNION
SELECT sale_price, sale_date FROM product WHERE (sale_price) IN (
SELECT
max(sale_price)
FROM product
WHERE product_name = 'PHONE'
) AND product_name = 'PHONE'
I am sure that there's an elegant way to query this. Any help is much appreciated. Thanks in advance!