0
您好,我想通過查詢中的mcap命令我的查詢,但我收到錯誤,但我找不到合適的解。這裏的查詢:MySQL子查詢錯誤錯誤1242(21000):子查詢返回多於1行
SELECT
c.code,
(e.total_value -
IFNULL((SELECT total_value FROM eod_stock WHERE company_id = e.company_id AND entry_date =
SELECT
entry_date FROM eod_stock WHERE entry_date < e.entry_date AND company_id = e.company_id ORDER
BY entry_date DESC LIMIT 0,1)),0))/
(SELECT total_value FROM eod_stock WHERE company_id = e.company_id AND entry_date = (SELECT entry_date FROM eod_stock WHERE entry_date < e.entry_date AND company_id = e.company_id ORDER BY entry_date DESC LIMIT 0,1)) AS turnover_growth,
(SELECT total_share FROM share_percentage WHERE company_code = c.code) * e.ltp AS mcap,
'' AS pe
-- ,e.*
FROM eod_stock AS e
LEFT OUTER JOIN company AS c
ON c.ID = e.company_id
WHERE e.company_id AND e.entry_date = (SELECT MAX(entry_date) FROM eod_stock)
ORDER BY mcap DESC
LIMIT 0,10;
但它返回一個錯誤:
ERROR 1242 (21000): Subquery returns more than 1 row
不知道哪裏出了問題。誰能幫我?
我知道但是如何解決它? –
是的第二個伎倆。謝謝。首先在邏輯上不正確cal total_share =! sum(total_share),即使它給MySQL錯誤也會產生錯誤的結果。 –