-1

SELECT new com.example.car.entities.MonthMapper(DATE_FORMAT(car.boughtDate,'%Y-%m'), SUM(total), COUNT(chassis_no)) FROM Car car WHERE DATE_FORMAT(car.boughtDate,'%Y/%m') >= DATE_FORMAT(:fromDate,'%Y/%m') GROUP BY DATE_FORMAT(car.boughtDate,'%Y/%m');

As I am already mentioning boughtDate after group by

  • Not sure but looking at other DATE_FORMAT parts of your query, you may want to replace "-" with "/" in the part: MonthMapper(DATE_FORMAT(car.boughtDate,'%Y-%m'). Also, this might be related: https://stackoverflow.com/questions/34115174/error-related-to-only-full-group-by-when-executing-a-query-in-mysql – Namandeep_Kaur Jul 02 '20 at 01:32
  • Error is still there after replacing "-" with "/", means after making both DATE_FORMAT same. Yes, I already looked into that link but I am not able to solve my issue specifically. – Muhammad Osama Khan Jul 02 '20 at 05:52
  • There's something missing after new SELECT new com. – P.Salmon Jul 02 '20 at 07:09

1 Answers1

0

The published code does not syntax on my local machine. Here's some errors

There's something missing after new SELECT new com com.example.car.entities.MonthMapper is possibly a column which should have a comma after it (DATE_FORMAT(car.boughtDate,'%Y-%m'), SUM(total), COUNT(chassis_no)) is incorrectly bracketed and should be (DATE_FORMAT(car.boughtDate,'%Y-%m')), SUM(total), COUNT(chassis_no)

Also I suspect there are too many nodes in com.example.car.entities.MonthMapper

P.Salmon
  • 17,104
  • 2
  • 12
  • 19