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
Receipt Fraud Window Detection
00:00
5 left

Receipt Fraud Window Detection

MediumSQL · PostgreSQL

Problem

Write a query to identify users who scanned receipts from the same retailer within a five-minute window, indicating potential fraud at Fetch.

Use the provided scan records and consider consecutive scans by the same user at the same retailer. Exclude scans with missing timestamps or unmatched users and retailers.

Output

  1. One row per qualifying consecutive scan pair
  2. Include user_id, user_name, retailer_id, retailer_name, both scan IDs and timestamps, and seconds_between
  3. Order by user_id, then the later scan timestamp, then the later scan ID

Schema

users
ColumnTypeDescription
user_idPKINTFetch user identifier
user_nameVARCHAR(100)User display name
retailers
ColumnTypeDescription
retailer_idPKINTRetailer identifier
retailer_nameVARCHAR(120)Retailer display name
receipt_scans
ColumnTypeDescription
scan_idPKINTReceipt scan identifier
user_idINTUser who scanned the receipt
retailer_idINTRetailer associated with the receipt
scanned_atTIMESTAMPTZTimestamp when the receipt was scanned
Tablesusersretailersreceipt_scans
Interviewer

Your question is Receipt Fraud Window Detection. Start with the requirements and the three 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.