I have two tables vehicles
and dealership_vehicles
. The dealership_vehicles
table has a price column. The vehicles
table has a column dealership_vehicle_id
which relates to the dealership_vehicles
id column in the dealership_vehicles
table.
I wanted to return just the vehicle make of the cheapest car.
Why is it that the following query:
select
vehicles.make,
MIN(dealership_vehicles.price)
from
vehicles inner join dealership_vehicles
on vehicles.dealership_vehicle_id=dealership_vehicles.id;
Returns the error:
column "vehicles.make" must appear in the GROUP BY clause or be used in an aggregate function
Since MIN function returns a single value it is plausible that SQL query can be constructed that will return a single value without needing GROUP BY.