select (sum(amount) and idoperation = 1) - (sum(amount) and idoperation = 2)
from journal group by idoperation
Но выполнение такого запроса сообщает о синтаксической ошибке.SELECT
SUM(ammount * (CASE WHEN idoperation = 1 THEN 1 ELSE -1 END)) AS result
FROM journal
;