分享一條大神寫(xiě)的sql鳞陨,查詢(xún)所有數(shù)據(jù),每條數(shù)據(jù)附帶前一條指定列:
SELECT
f.ts_code,
@prev AS pre_adj_factor,
f.trade_date,
@prev := f.adj_factor AS adj_factor
FROM
( SELECT @prev := NULL ) AS i,
syn_factors AS f
WHERE
ts_code = '000001.SZ'
ORDER BY
f.trade_date