51. How do you find common records between two tables?
Use INNER JOIN or INTERSECT.
52. How do you find records in table A not in B?
Use LEFT JOIN ... IS NULL or NOT EXISTS.
53. How do you find records in B not in A?
Use reverse LEFT JOIN or NOT EXISTS.
54. How do you merge data from two tables?
Use UNION, JOIN, or MERGE based on need.
55. How do you combine results from two queries?
Use UNION or UNION ALL.
56. Difference between UNION and UNION ALL?
UNION removes duplicates; UNION ALL keeps all rows.
57. How do you find intersection of two tables?
Use INTERSECT.
58. How do you update one table from another?
Use UPDATE with JOIN.
59. How do you insert missing records from one table to another?
Use INSERT INTO ... SELECT with NOT EXISTS.
60. How do you synchronize two tables?
Use MERGE.
61. How do you detect slowly changing data?
Compare current and incoming records using business key.
62. How do you implement SCD Type 1?
Overwrite old value with new value.
63. How do you implement SCD Type 2?
Expire old record and insert new record with version/date.
64. How do you implement SCD Type 3?
Store current and previous value in same row.
65. How do you load only changed records?
Use incremental load with timestamp or CDC logic.
66. How do you validate row counts after ETL?
Compare source and target row counts.
67. How do you validate duplicate data after load?
Run duplicate checks on business key.
68. How do you identify rejected records?
Filter rows failing validation rules.
69. How do you audit data load?
Store load date, row count, status, and error logs.
70. How do you troubleshoot missing records in target?
Compare source vs target using keys and load filters.
SQL Scenario-Based Interview Questions ( 51 - 70)
ReplyDelete