Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. with substract as (
  2. with ac_c as(
  3.     select t.id, t.dt, t.ac
  4.     from table_1 t
  5.     where t.ac is not NULL
  6. ),
  7. co_c as(
  8.     select t.id, t.dt, t.co
  9.     from table_1 t
  10.     where t.co is not NULL
  11. )
  12. select (date(co_c.dt)-date(ac_c.dt)) as subs
  13. from ac_c, co_c
  14. where ac_c.id = co_c.id
  15. )
  16.  
  17. select subs, count(*)
  18. from substract
  19. group by subs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement