Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
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 feedbackSuccess 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
SQL Query Review
00:00
5 left

SQL Query Review

HardSQL · PostgreSQL

Problem

Review this SQL query and table definition for Mercury and tell me what performance issues, security vulnerabilities, or anti-patterns you see.

Assess the query structure, parameter handling, indexing needs, authorization boundaries, and maintainability. Provide a corrected executable query using representative constant values rather than driver placeholders.

Output

  1. Return one row per settled payment for account 101 during January 2026.
  2. Include account_id, account_name, payment_id, amount, currency, and created_at.
  3. Order by created_at descending, then payment_id descending.

Schema

mercury_accounts
ColumnTypeDescription
account_idPKINTEGERUnique Mercury account identifier
account_nameVARCHAR(120)Display name for the account
mercury_payments
ColumnTypeDescription
payment_idPKBIGINTUnique payment identifier
account_idINTEGERAccount receiving or sending the payment
amountNUMERIC(14,2)Payment amount in the stated currency
currencyVARCHAR(3)ISO currency code
statusVARCHAR(20)Payment processing status
created_atTIMESTAMPTZPayment creation timestamp
Tablesmercury_accountsmercury_payments
Interviewer

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