Guest User

Untitled

a guest
Oct 23rd, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. select
  2. sum(case when type='credit' then amount else -amount end)
  3. from report;
  4.  
  5. select
  6. sum(case when type='credit' then amount
  7. else -amount end)
  8. from report
  9. where type in ('credit', 'debit');
  10.  
  11. select (
  12. select sum(case when type='credit' then amount else -amount end)
  13. from report
  14. ) - (select sum(amount) from total);
  15.  
  16. select sum(case type when 'credit' then amount when 'debit' then -amount else 0 end)
  17. from report
Add Comment
Please, Sign In to add comment