Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT p.client_id AS CLIENT, SUM(p.sum)-_inner.Issuance AS SALDO
- FROM processing AS p
- INNER JOIN
- (
- SELECT client_id, SUM(sum) AS Issuance FROM processing
- WHERE operation_id =
- (
- SELECT id FROM operation WHERE name = 'issuance'
- )
- GROUP BY client_id, operation_id
- )
- AS _inner
- ON _inner.client_id = p.client_id
- WHERE p.operation_id =
- (
- SELECT id FROM operation WHERE name = 'payment'
- )
- GROUP BY p.client_id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement