Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with substract as (
- with ac_c as(
- select t.id, t.dt, t.ac
- from table_1 t
- where t.ac is not NULL
- ),
- co_c as(
- select t.id, t.dt, t.co
- from table_1 t
- where t.co is not NULL
- )
- select (date(co_c.dt)-date(ac_c.dt)) as subs
- from ac_c, co_c
- where ac_c.id = co_c.id
- )
- select subs, count(*)
- from substract
- group by subs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement