Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.sql.SQLException: Invalid use of group function

From this query:

select count(*) as data, LOCATION_Name as location 
from SPECIAL_PROCEDURE_COLLECTION_FINAL_temp_final 
where sno>=6973 
  and sno<= 7251 
  and date(PAYMENT_DATE) = '2021-07-31' 
  and Procedures_Category IN ('FFA-VR') 
  and SUM(BILLED_AMOUNT)= 0 
group by LOCATION_Name

I am getting this error:

java.sql.SQLException: Invalid use of group function

What is the issue?

like image 376
Atul Avatar asked Dec 30 '25 17:12

Atul


1 Answers

You cannot use an aggregate function in the where clause. Kindly change yor query to:

select count(*) as data, LOCATION_Name as location 
from SPECIAL_PROCEDURE_COLLECTION_FINAL_temp_final 
where sno>=6973 and sno<= 7251 and 
date(PAYMENT_DATE) = '2021-07-31' and Procedures_Category IN ('FFA-VR') 
 group by LOCATION_Name
Having SUM(BILLED_AMOUNT)= 0
like image 194
Mannu Avatar answered Jan 02 '26 11:01

Mannu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!