DB/MYSQL

[ MYSQL ] 중복 검증 쿼리

HEON.D 2022. 6. 14. 14:44
SELECT
    user_id,
    count(user_id) AS total,
    count(distinct device_token) AS token,
    IF( count(user_id) != count(distinct device_token), '불일치', '일치') AS duplicated
FROM USER_DEVICE AS UD GROUP BY user_id ORDER BY total DESC;