Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Incremental Load SQL Query
00:00
5 left

Incremental Load SQL Query

MediumSQL · PostgreSQL

Problem

Write a SQL query to handle incremental data loads from a source table.

Use finacle_source_accounts as the source and finacle_account_snapshot as the target. Load records newer than the target's latest loaded timestamp, retain only the newest source version per account, and insert or update the target.

Output

  1. Return account_id, customer_name, status, balance, and source_updated_at for rows loaded or updated.
  2. Sort by account_id ascending.

Schema

finacle_source_accounts
ColumnTypeDescription
source_row_idPKINTUnique source extract row identifier
account_idINTFinacle account identifier
customer_nameVARCHAR(100)Account holder name
statusVARCHAR(20)Account status from the source
balanceNUMERIC(12,2)Account balance
source_updated_atTIMESTAMPSource system modification timestamp
finacle_account_snapshot
ColumnTypeDescription
account_idPKINTFinacle account identifier
customer_nameVARCHAR(100)Account holder name
statusVARCHAR(20)Latest loaded account status
balanceNUMERIC(12,2)Latest loaded account balance
source_updated_atTIMESTAMPLatest source timestamp loaded
Tablesfinacle_source_accountsfinacle_account_snapshot
Interviewer

Your question is Incremental Load SQL Query. 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.