Jordan Savant # Software Engineer

-- Example 1
SELECT dup.count, c.file_type_id, c.title, c.description, c.original_file_name, c.created_at, c.server_path
FROM cms_files c
INNER JOIN
(
    SELECT count(id) as count, id, original_file_name, server_path
    FROM cms_files
    GROUP BY original_file_name, server_path
    HAVING count(id) > 1
) dup
ON c.id = dup.id

-- Example 2
SELECT dup.count, c.question, c.type, c.domain_id, c.export_name
FROM twodialog_ugm.twodialog_customquestion c
INNER JOIN
(
    SELECT count(id) as count, id, question, export_name
    FROM twodialog_ugm.twodialog_customquestion
    GROUP BY export_name
    HAVING count(id) > 1
) dup
ON c.id = dup.id;