HomeInterview QuestionsFind duplicate cards from the table.

Find duplicate cards from the table.

🟢 Easy Coding Junior level
1Times asked
Jul 2026Last seen
Jul 2026First seen

💡 Model Answer

Assuming the table is named cards and the column that identifies a card is card_id, you can find duplicates with:

SELECT card_id, COUNT(*) AS dup_count

FROM cards

GROUP BY card_id

HAVING COUNT(*) > 1;

If you need the full duplicate rows, use:

WITH dup AS (

SELECT card_id

FROM cards

GROUP BY card_id

HAVING COUNT(*) > 1

)

SELECT c.*

FROM cards c

JOIN dup d ON c.card_id = d.card_id;

This returns every record that shares a card_id with at least one other record.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500