0
當前SELECT查詢需要幫助辦成一個加入
SELECT a.*, ROUND(((a.avg-b.avg)/b.avg)*100,2) pct_change
FROM
(
SELECT x.*, COUNT(*) rank
FROM blavg x
JOIN blavg y
ON y.bline_id = x.bline_id
AND y.id >= x.id
GROUP BY x.id
) a
JOIN
(
SELECT x.*, COUNT(*) rank
FROM blavg x
JOIN blavg y
ON y.bline_id = x.bline_id
AND y.id >= x.id
GROUP BY x.id
) b
ON b.bline_id = a.bline_id
AND b.rank = a.rank+1
WHERE a.rank = 1;
我想也
SELECT bl_id, bline FROM bl
bl.bl_id = blavg.bline_id
我已經試過
SELECT bl_id, bline
FROM bl bl
LEFT JOIN ON bl.bl_id = blavg.bline_id
但不知道我是否有正確的語法,我不確定在哪裏添加ON
以及parens()去哪裏。
任何幫助將不勝感激。
你得到什麼錯誤? – Deruijter