Hello, I want to order my query by mcap which is in the query but I'm getting error, I've googled but couldn't find suitable solution. Here's the query:
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;
but it returns an error:
ERROR 1242 (21000): Subquery returns more than 1 row
Don't know what went wrong. Can anyone help me?