This query is marked as a draft This query has been published by CptViraj.

SQL

AخA
 
SELECT
    u.user_name,
    ug.*,
    other_groups.*
FROM
    user_groups ug
JOIN
    (
        SELECT
            other.ug_user AS user_id,
            GROUP_CONCAT(
                CONCAT(
                    other.ug_group,
                    CASE
                        WHEN other.ug_expiry IS NOT NULL THEN CONCAT('-', other.ug_expiry)
                        ELSE ''
                    END
                )
            ) AS user_groups
        FROM
            user_groups other
        WHERE
            other.ug_group IN ('image-reviewer', 'patroller', 'sysop', 'bot')
        GROUP BY other.ug_user
    ) AS other_groups
    ON other_groups.user_id = ug.ug_user
JOIN
    user u
    ON u.user_id = ug.ug_user
WHERE
    ug.ug_group = 'autopatrolled'
;
By running queries you agree to the Cloud Services Terms of Use and you irrevocably agree to release your SQL under CC0 License.
All SQL code is licensed under CC0 License.

Checking query status...