Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL Update/Delete Constraints
00:00
5 left

SQL Update/Delete Constraints

HardSQL · PostgreSQL

Problem

Explain how you would delete or update rows in Salesforce using only SELECT and INSERT operations.

Provide a PostgreSQL statement that reads the Salesforce contact snapshot and inserts a change plan representing required updates or deletions. Do not directly modify the snapshot table.

Output

  1. One row per eligible contact, with plan_id, contact_id, operation, replacement_status, and replacement_phone.
  2. Include inactive contacts, contacts with missing phone numbers, and deleted contacts. Sort by contact_id ascending.

Schema

salesforce_contact_snapshot
ColumnTypeDescription
contact_idPKINTSalesforce Contact identifier
statusVARCHAR(20)Current Contact status
phoneVARCHAR(20)Current phone number
is_deletedBOOLEANWhether Salesforce marked the Contact as deleted
salesforce_contact_change_plan
ColumnTypeDescription
plan_idPKINTChange plan identifier
contact_idINTReferenced Salesforce Contact identifier
operationVARCHAR(10)Planned operation, UPDATE or DELETE
replacement_statusVARCHAR(20)Status to apply for an update
replacement_phoneVARCHAR(20)Phone number to apply for an update
Tablessalesforce_contact_snapshotsalesforce_contact_change_plan
Interviewer

Your question is SQL Update/Delete Constraints. Start with the requirements and the two tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.