SyntaxFix
Write A Post
Hire A Developer
Questions
Please try this,
SELECT c.Id, c.name, (SELECT pi.price FROM purchase pi WHERE pi.Id = MAX(p.Id)) AS [LastPurchasePrice] FROM customer c INNER JOIN purchase p ON c.Id = p.customerId GROUP BY c.Id,c.name;