Imagine the following financial trade and quote data in an MS SQL Server table called "tblPrices".
SeqNo Ticker TradeType JulianTime Price BidPrice AskPrice
1 CLK4 Quote 735706.11 NULL 103 NULL
2 CLK4 Quote 735706.59 NULL NULL 105
3 CLK4 Trade 735706.59 103 NULL NULL
NULL is used to conserve space in the table. When extracting 'TradeType' data of value 'Trade', I also want to extract the most recent 'BidPrice' and 'AskPrice' which is not NULL based on JulianTime.
ie. Output for SeqNo 3 above could be:
JulianTime TradeType Price BidPrice AskPrice
735706.59 Trade 103 103 105
Note: SeqNo is an identity of step size 1. JulianTime is a numerical value for DateTime invented by MATLAB.
How can I do this?