SyntaxFix
Write A Post
Hire A Developer
Questions
Best performance and easy to use:
SELECT id, code, SUBSTRING_INDEX( GROUP_CONCAT(price ORDER BY id DESC), ',', 1) first_found_price FROM stocks GROUP BY code ORDER BY id DESC