Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Understanding Transactions and SQL Queries
00:00
5 left

Understanding Transactions and SQL Queries

MediumSQL · PostgreSQL

Problem

What is transaction, write few sql queries

Asked in the Round 2 - Technical stage. Write PostgreSQL statements that demonstrate an atomic account transfer, recording the transfer only when the debit and credit succeed.

Output

  1. One row for transfer 2001
  2. Columns: transfer_id, sender_name, recipient_name, amount, sender_balance, recipient_balance
  3. Show the balances after the transfer and order by transfer_id ascending

Schema

accounts
ColumnTypeDescription
account_idPKINTUnique account identifier
account_nameVARCHAR(100)Account holder name
balanceNUMERIC(12,2)Current account balance
transfers
ColumnTypeDescription
transfer_idPKINTUnique transfer identifier
from_account_idINTAccount sending the funds
to_account_idINTAccount receiving the funds
amountNUMERIC(12,2)Transferred amount
transferred_atDATETransfer date
memoVARCHAR(200)Optional transfer note
Tablesaccountstransfers
Interviewer

Your question is Understanding Transactions and SQL Queries. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.