I am new to MySQL and I am trying to solve a problem for a project.
I have three tables: cars, sales and customers. cars has VID as pk and some other attributes like model and price. customers has CID as pk and some attributes. sales has (VID,CID) as pk and a sales price and sales date as attributes.
The question is: "What is the model of car, that was sold most often in 2014"?
Here is my query
Select Model
From Cars,Sales
Where Cars.VID=Sales.VID
Group By Cars.VID
Having MAX( (Select count(*)
From Cars,Sales Where Cars.VID=Sales.VID AND SellDate Between '2014-01-01' And '2014-12-30'));
I still get all the models, that exist in the sales table, Could tell me what is wrong?