我有这个查询:
SELECT
s.last_spread, s.sd, s.mean, s.id
,c.id_ticker, c.coef
,t.ticker
,/*p.last,*/ p.price
FROM (SELECT * FROM spreads WHERE spreads.id_check=1 LIMIT 60,896) as s
INNER JOIN coef as c
ON c.id_spread = s.id
INNER JOIN tickers AS t
ON t.id = c.id_ticker
LEFT JOIN (SELECT prices.id_ticker, MAX(prices.date) as last, prices.price FROM prices GROUP BY prices.id_ticker) AS p
ON p.id_ticker = t.id
ORDER BY s.id, c.id
最后一个 JOIN 没有返回正确的值....我需要获取代码的最后价格(所以每个代码的最后一行)。
在它返回第一个价格的那一刻,我如何更改整个查询以获取每个 ticker.id 的最后价格?( p.id_ticker = t.id
)
谢谢!