I have the following table:
listId | accountId | amount 
1        1           20
1        1           20
2        2           30
2        2           30
I need to SUM(amount) and group by listId, accountId to get result:
 listId | accountId | amount | 
 1        1           40
 2        2           60
But it does not work for me: SUM(amount) ... GROUP BY listId, accountId
My full query is:
select `account_transactions`.*, 
`enterprise_invoces`.*, 
ABS(SUM(IF(AT_amount>0, AT_amount, 0))) AS debit, 
ABS(SUM(IF(AT_amount<0, AT_amount, 0))) AS credit 
from `account_transactions` 
inner join `enterprise_invoces` 
on `enterprise_invoces`.`AC_id` = `account_transactions`.`AT_code` 
where `AT_createuser` = 15 and 
date(`AT_transactiondatetime`) >= 2019-04-11 and
date(`AT_transactiondatetime`) <= 2019-07-29 and 
`AC_code` >= 601 and
`AC_code` <= 761 
group by `enterprise_invoces`.`AC_id`, `account_transactions.AT_transactionficheno` 
order by `AT_transactiondatetime` desc
 
     
    