Assuming that date is not just the date, but the timestamp of the market price, you can write three separate (and simple) queries like this:SELECT CAST([date] AS DATE) AS [Date], MIN(price), MAX(price)FROM YourTableGROUP BY CAST([date] AS DATE);
For opening price:SELECT * FROM( SELECT *, ROW_NUMBER() OVER (PARTITION BY CAST([date] AS DATE) ORDER BY [date] ASC ) AS OpenN FROM YourTable)sWHERE OpenN = 1ORDER BY [date];
A similar one for closing price - change ASC to DESC in the order by clause on row_number.The queries can be combined into one, but that would make it more complex and perhaps even less efficient.