SELECT TOP (100) PERCENT id, TradingDay, InstrumentID, LastPrice, PreClosePrice, OpenPrice, HighestPrice, LowestPrice,
Volume, LowerLimitPrice, UpdateTime, ActionDay
FROM dbo.t_test
ORDER BY InstrumentID, ActionDay, UpdateTime(视图)
select * from
(
select top 10000 *, (
volume - LAG(volume, 1,0) over (order by instrumentid asc, actionday asc, updatetime asc)
)
as vol from v_order
) as tmpvol
where vol <>0 order by instrumentid asc, actionday asc, updatetime asc(查询减去前面的条目)