Hi, I have an SQL pricing table where one of the columns is date, another is the price information.
How do I select the rows with earliest date where the price is null?
There are multiple funds in the table, each fund can have different date which the earliest date is null. How do I display all these rows with the earliest date?
E.g. Fund 1, 23 January
Fund 2, 10 March
Fund 3, 9 April
These dates are the earliest dates for each fund that price is null.
I am currently using this code
select dbo.Benchmark_Details.BenchmarkID, Date from dbo.Benchmark_Details where date in (select top 1 date from dbo.Benchmark_Details where Benchmark_Price is null order by date)
but this takes the earliest of all the dates and applies it to all the funds instead of each fund having its earliest date individually. Also if the dates are not the same then sometimes it returns blank result