Skip to main content
1 de 5
doeJohn
  • 1
  • 1
  • 3

How to select max value from one table and his related value from another table

I want a query for selecting maximum price for each maker and the corresponding model, the field I must use to join the tables is the model. I'm using the next query:

select a.model as modelo, max(a.price) as precio, b.maker as fabricante from pc a , product b where a.model = b.model group by a.model, b.maker

More than one model is related to one maker. because of this the query is not grouping by maker.

How should I modify it to show only the model, maker and maximum price.

doeJohn
  • 1
  • 1
  • 3