Reviewed by Aditya Kumar · Last reviewed 2026-03-24
**Single column**: SELECT col, COUNT(*) FROM t GROUP BY col HAVING COUNT(*) > 1. **Two columns**: GROUP BY col1, col2 HAVING COUNT(*) > 1. **Full rows**: SELECT * FROM t WHERE (col1, col2) IN (SELECT col1, col2 FROM t GROUP BY col1, col2 HAVING COUNT(*)>1). **Dedup strategy**:...
Single column: SELECT col, COUNT() FROM t GROUP BY col HAVING COUNT() > 1. Two columns: GROUP BY col1, col2 HAVING COUNT() > 1. Full rows: SELECT FROM t WHERE (col1, col2) IN (SELECT col1, col2 FROM t GROUP BY col1, col2 HAVING COUNT(*)>1). Dedup strategy: ROW_NUMBER() OVER (PARTITION BY key ORDER BY ts DESC) to keep first/last. Index: Grouped columns.
Red Flag: Deduping without defining 'winning' row. Pro-Move: 'We used ROW_NUMBER() ORDER BY updated_at DESC, id—deterministic keep-latest; 3M duplicates removed, schema documented.'
According to DataEngPrep.tech, this is one of the most frequently asked SQL interview questions, reported at 1 company. DataEngPrep.tech maintains an editor-reviewed database of 1,863 data engineering interview questions across 7 categories.