Q:

In aggregated query without GROUP BY, expression

My query is running well in local server but in live server its getting error.
my local Server version: 10.1.36-MariaDB - mariadb.org binary distribution
and live Server version: 5.7.25-cll-lve - MySQL Community Server - (GPL)
Error message:
In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'uzzal_management.employee.id'; this is incompatible with sql_mode=only_full_group_by
Query:
SELECT `employee`.*, 

(SELECT `des_name` FROM `designation` 
WHERE `employee`.`des_id` = `designation`.`id`) AS name, 

(SELECT `dep_name` FROM `department` 
WHERE `employee`.`dep_id` = `department`.`id`) AS dep_name, 

`emp_salary`.`total`, 
`bank_info`.*, 
`addition`.*, 
`deduction`.*, 

(SELECT TRUNCATE((SUM(ABS(( TIME_TO_SEC( TIMEDIFF( `signin_time`, `signout_time` ) ) )))/3600), 1) AS Hours FROM `attendance` 
WHERE (`attendance`.`emp_id`='Gup1410') AND (DATE_FORMAT(`attendance`.`atten_date`, '%m'))=MONTH(CURRENT_DATE())) AS hours_worked,COUNT(*) AS days FROM `employee` 

LEFT JOIN `department` ON `employee`.`dep_id`=`department`.`id` 
LEFT JOIN `addition` ON `employee`.`em_id`=`addition`.`salary_id` 
LEFT JOIN `deduction` ON `employee`.`em_id`=`deduction`.`salary_id` 
LEFT JOIN `bank_info` ON `employee`.`em_id`=`bank_info`.`em_id` 
LEFT JOIN `emp_salary` ON `employee`.`em_id`=`emp_salary`.`emp_id` 

WHERE `employee`.`em_id`='Gup1410'

A:

go to variable and check for sql_mode there you will find out ONLY_FULL_GROUP_BY, remove it and save it. it will work.

