Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select
- sum(case when type='credit' then amount else -amount end)
- from report;
- select
- sum(case when type='credit' then amount
- else -amount end)
- from report
- where type in ('credit', 'debit');
- select (
- select sum(case when type='credit' then amount else -amount end)
- from report
- ) - (select sum(amount) from total);
- select sum(case type when 'credit' then amount when 'debit' then -amount else 0 end)
- from report
Add Comment
Please, Sign In to add comment