daily pastebin goal
30%
SHARE
TWEET

Untitled

a guest Mar 19th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT
  2. pa_coduni,
  3. pa_proc_id,
  4. sum(case when substr(pa_cmp, 1, 4) = 2017 then pa_qtdapr else 0 end) a2017,
  5. sum(case when substr(pa_cmp, 1, 4) = 2018 then pa_qtdapr else 0 end) a2018,
  6. sum(pa_qtdapr) total
  7. FROM
  8. bacabalma
  9. where
  10. substr(pa_cmp, 1, 4) >= 2017
  11. group by
  12. pa_coduni, substr(pa_cmp, 1, 4), pa_proc_id
  13. order by
  14. pa_coduni, pa_proc_id
  15.      
  16. pa_coduni | pa_proc_id | a2017 | a2018 | total
  17. aaa       |aaaa        | 1     | 0     | 1
  18. aaa       |aaaa        | 0     | 1     | 1
  19.      
  20. pa_coduni | pa_proc_id | a2017 | a2018 | total
  21. aaa       |aaaa        | 1     | 1     | 2
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top