I am trying to write a query where for each day I get the minimum and maximum price for each item from price details table.
In price details table prices are set mul
A simple group by
should work:
select cast(price_set_date as date) as [Date]
, exch_ticker
, min(buy_price) as MinPrice
, max(buy_price) as MaxPrice
from price_details as p
group by
exch_ticker
, cast(price_set_date as date)
Not sure why your example query is using a self join. If there's a good reason please add an explanation to your question.