select distinct c.device_id from (select
    a.device_id
from
    user_profile a,
    question_practice_detail b
where
    a.device_id = b.device_id
group by
    b.device_id
having
    count(question_id) > 2
union all
select
    device_id
from
    user_profile
where
    university = '北京大学') c order by device_id desc