MySQL finding the most expensive in each zip code

前端 未结 4 414
盖世英雄少女心
盖世英雄少女心 2021-01-22 06:36

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

4条回答
  •  伪装坚强ぢ
    2021-01-22 07:19

    Something like this:

    SELECT name,price,zip_code
    FROM products
    WHERE state='NJ' AND price=(SELECT MAX(price) FROM products)
    

提交回复
热议问题