SQL QuestSQL Interview Questions › Joins

Cross-Account Collusion — Shared Device Fingerprint

MediumFreeQuerying BasicsJoins

Synthetic-identity fraud signature: multiple accounts created on the same device share a device_fingerprint. Find every PAIR of accounts that share a fingerprint — production fraud teams add IP blocks, browser fingerprints, and behavioral patterns on top, but device alone catches the obvious cases.

Use a self-join with a1.account_id < a2.account_id to avoid double-counting and self-pairs. Show account_a, account_b, device_fingerprint, a_signup, b_signup, hours_apart (rounded to 1 decimal — accounts created within hours of each other are the most suspicious).

Order by hours_apart ascending (closest signups first).

Solve it in the browser editor →

Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".

Schema

accounts

account_idemailsignup_atcountrydevice_fingerprintip_blockstatus
1user1@example.com2026-02-24T00:00:00.000ZTRdev_13c0cdad41.116.196.153active
2user2@inbox.dev2025-05-13T00:00:00.000ZJPdev_26576d4938.98.201.102active
3user3@inbox.dev2026-04-25T00:00:00.000ZJPdev_42f1a115190.77.45.244flagged

Expected output: Account pairs sharing a device

Hint

FROM accounts a1 JOIN accounts a2 ON a1.device_fingerprint = a2.device_fingerprint AND a1.account_id < a2.account_id. The < (not !=) prevents the (1,2) and (2,1) duplicate pairs.

Concepts

SELECT Self-JOIN WHERE Self-Join

Practise the topic: SQL practice questions · JOIN practice

Related questions

Customers Who Never OrderedMedium · FreeAbove-Average Departments (Derived Table)Medium · FreeLEFT JOIN NULL Semantics: Inactive CustomersMedium · FreeManagement Hierarchy OverviewMedium · FreeCount Direct ReportsMedium · FreeCustomer Recency AnalysisMedium · Free

Where would this cost you points in an interview?

Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.

Take the readiness test