Home › Interview Questions › These are two tables: all_system_orders and new_sy…

These are two tables: all_system_orders and new_system_orders. Data has been transferred; how would you validate that the data has been correctly imported? Write queries to validate the data.

🟡 Medium Coding Junior level
1Times asked
May 2026Last seen
May 2026First seen

💡 Model Answer

To validate the import, first compare row counts: SELECT COUNT() FROM all_system_orders; SELECT COUNT() FROM new_system_orders; They should match. Next, verify key columns: SELECT order_id FROM all_system_orders EXCEPT SELECT order_id FROM new_system_orders; should return no rows. Check aggregates: SELECT SUM(total_amount) FROM all_system_orders; SELECT SUM(total_amount) FROM new_system_orders; They should be equal. For a deeper check, compute a checksum per row: SELECT order_id, MD5(CONCAT(order_date, customer_id, total_amount)) AS chk FROM all_system_orders; JOIN the same on new_system_orders and compare chk values. Finally, sample a few rows: SELECT * FROM all_system_orders ORDER BY RANDOM() LIMIT 10; and compare with new_system_orders. Complexity is O(n) for counts and checksums, O(k) for samples. This systematic approach ensures data integrity after migration.

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 — invisible to screen sharing.

Get Assisting AI — Starts at ₹500