Hi all,
I have a table-TableCars. It has one column-[Cartype], in which the PK is all the car manufacturers I am repairing-say Fiat, Ford, Audi, Saab and BMW.
I have another table-Table2020 which has two columns-the PK is the job ref number-[Jobno] and the second column [Car] tells the car manufacturer from the above list that I have repaired in the year 2020.
I have two more tables-Table2021, and Table2022, both following the same pattern as Table2020.
Can anyone advise how I could write a query to show how many cars each year, so I can see increase/decrease etc?
2020 2021 2022 Fiat 15 99 456 Ford 16 45 44 Audi 3 0 0 Saab 6 7 3 BMW 21 26 29
I am struggling with the code below:
Any input appreciated.Code:SELECT TableCars.CarType, Count([Table2020].Jobno) AS CountOfJobno, Count([Table2021].Jobno) AS CountOfJobno1, Count([Table2022].Jobno) AS CountOfJobno2 FROM ((TableCars LEFT JOIN Table2020 ON TableCars.CarType = [Table2020].Car) LEFT JOIN Table2021 ON TableCars.CarType = [Table2021].Car) LEFT JOIN Table2022 ON TableCars.CarType = [Table2022].Car GROUP BY TbSampleType.CarType;
Thanks,
Mattbro451