I get an error as given below
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'np_bo.fdm.field_deposit_amount_value' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by:
for the code as given below:
$sql = "SELECT n.nid, fg.field_guest_target_id as guest, fdm.field_deposit_amount_value as deposit,
if(sum(fau.field_amount_used_value) IS NULL, 0, sum(fau.field_amount_used_value)) as used ,
if((fdm.field_deposit_amount_value - sum(fau.field_amount_used_value)) IS NULL, fdm.field_deposit_amount_value ,(fdm.field_deposit_amount_value - sum(fau.field_amount_used_value))) as leftamount
FROM node n
INNER JOIN field_data_field_guest fg ON n.nid = fg.entity_id
INNER JOIN field_data_field_deposit_status fds ON n.nid = fds.entity_id
INNER JOIN field_data_field_deposit_amount fdm ON n.nid = fdm.entity_id
LEFT JOIN field_data_field_deposit_utilized fdu ON fdu.entity_id = n.nid
LEFT JOIN field_data_field_amount_used fau ON fau.entity_id = fdu.field_deposit_utilized_value
LEFT JOIN field_data_field_bill_status fbs ON fbs.entity_id = fdu.field_deposit_utilized_value
WHERE type = 'deposit_sale' and
fg.field_guest_target_id = :guest and
fds.field_deposit_status_value = 'open' and
(fbs.field_bill_status_value <> 'Nullified' OR fbs.field_bill_status_value IS NULL)
GROUP BY n.nid
ORDER BY n.nid limit 1";
$options = array(':guest' => $guest);
$deposit_sales = db_query($sql, $options)->fetchAssoc();
return $deposit_sales;
what should be the error? and steps I need to adopt to fix it?