SELECT b.sc_name AS company, sum( a.st_qty ) AS 'shares', (
SELECT c.sh_value
FROM stock_history c
WHERE c.sh_id = b.sc_id
ORDER BY c.sh_date DESC
LIMIT 1
) AS 'value'
FROM stock_transaction a
INNER JOIN stock_company b ON a.st_company = b.sc_id
WHERE a.st_owner =1
GROUP BY b.sc_name ASC
|