with s as ( select distinct device_id, date from question_practice_detail) select (select count(*) from s where (device_id, date) in (select device_id, date+1 from s))/count(*) from s
with s as ( select distinct device_id, date from question_practice_detail) select (select count(*) from s where (device_id, date) in (select device_id, date+1 from s))/count(*) from s