I have table cars:
Id int,
Model nvarchar(max),
DateOfProduction (datetime).
And data like:
1 BMW X5 1.1.2010
2 BMW X5 1.1.2009
3 BMW X3 1.1.2008
4 BMW X3 1.1.2007
5 BMW X7 1.1.2005
And I want to get newest car for each model:
1 BMW X5 1.1.2010
3 BMW X3 1.1.2008
5 BMW X7 1.1.2005
I can’t cope with this:/
Could you help me ?
For your given table structure, following SQL returns what you need but you might consider changing your table structure into something like this
SQL Statement