I have a table called Products with the schema (name, city, state, zip_code price).
And I want to find the most expensive products\' name for a given state\'s each zip_c
This should work, though I can't vouch for it's efficiency. Per comment, here's an update that pulls back all records with price equal to the max price per zip code.
SELECT *
FROM products p1
WHERE p1.state = 'NJ'
AND p1.price = (select max(price) from products p2
where p1.zip_code = p2.zip_code)
http://www.sqlfiddle.com/#!2/98f6d/2