user1667128
user1667128

Reputation:

MySQL query search with 3 tables

I have a
vehicle (vin, vmaker, vmodel, vyear)
customer (SSN, cname, cgender, ccity)
buyvehicle (BVSSN, BVVin, price, year)

I need a query that finds the vehicle with the highest sale price for each maker.

Please help!

example: Honda Civic $20000
Honda Accord $25000
BMW 3 Series $22000
BMW 5 Series $40000

the result should be:
Honda Accord
BMW 5 Series

Upvotes: 0

Views: 62

Answers (1)

Taryn
Taryn

Reputation: 247810

If you are looking for the vehicle with the highest price you should be able to use something like this:

select v.vmaker, max(b.price) price
from vehicle v
left join buyvehicle b
    on v.vin = b.bvvin
group by v.vmaker

Upvotes: 1

Related Questions