Pattern · Database

Database interview questions

87 database problems tagged across recent interview reports. Drilled most heavily by tcs, google, and deloitte.

Founder's read

Database problems test your ability to query, join, and transform structured data under pressure. With 87 problems in this category, it's a core pattern across financial services, tech, and consulting firms. Google, TCS, and Deloitte weight these heavily in their online assessments. You'll face schema design, multi-table joins, window functions, and aggregation logic, often with tricky edge cases around nulls, duplicates, and time-based filtering. If a complex Database problem lands in your live OA and you freeze, StealthCoder reads the schema and generates the SQL in seconds, invisible to the proctor.

Most-asked database problems

#ProblemDiff# Companies
01Article Views IEASY5
02Department Top Three SalariesHARD5
03Managers with at Least 5 Direct ReportsMEDIUM5
04Consecutive NumbersMEDIUM4
05Average Time of Process per MachineEASY3
06Big CountriesEASY3
07Delete Duplicate EmailsEASY3
08Department Highest SalaryMEDIUM3
09Duplicate EmailsEASY3
10Employees Earning More Than Their ManagersEASY3
11Find Customer RefereeEASY3
12Immediate Food Delivery IIMEDIUM3
13Employee BonusEASY2
14Invalid TweetsEASY2
15Active BusinessesMEDIUM1
16Active UsersMEDIUM1
17Activity ParticipantsMEDIUM1
18Bank Account SummaryMEDIUM1
19Capital Gain/LossMEDIUM1
20Change Null Values in a Table to the Previous ValueMEDIUM1
21Classifying Triangles by LengthsEASY1
22Combine Two TablesEASY1
23Count Student Number in DepartmentsMEDIUM1
24Create a Session Bar ChartEASY1
25Customer Placing the Largest Number of OrdersEASY1
26Evaluate Boolean ExpressionMEDIUM1
27Exchange SeatsMEDIUM1
28Find Candidates for Data Scientist PositionEASY1
29Find Followers CountEASY1
30Find Longest CallsMEDIUM1
31Find Median Given Frequency of NumbersHARD1
32Find Peak Calling Hours for Each CityMEDIUM1
33Find Third TransactionMEDIUM1
34Find Users With Valid E-MailsEASY1
35Game Play Analysis IEASY1
36Game Play Analysis IIEASY1
37Game Play Analysis IIIMEDIUM1
38Game Play Analysis IVMEDIUM1
39Game Play Analysis VHARD1
40Group Employees of the Same SalaryMEDIUM1
41Highest Grade For Each StudentMEDIUM1
42Human Traffic of StadiumHARD1
43Immediate Food Delivery IEASY1
44Investments in 2016MEDIUM1
45Last Person to Fit in the BusMEDIUM1
46Leetcodify Friends RecommendationsHARD1
47Leetcodify Similar FriendsHARD1
48Leetflex Banned AccountsMEDIUM1
49Market Analysis IMEDIUM1
50Market Analysis IIHARD1

Showing top 50 of 87 database problems by # companies asking.

The hedge for the live OA

You can't drill every database variant before the assessment. StealthCoder runs invisibly during screen share and solves whichever variant they throw at you. No browser extension. No detection signature. Made for the engineer who has done the work but might still blank with a webcam pointed at him.

Get StealthCoder
What this means

Database problems fall into a few clear buckets: SELECT and filter tasks (like "active-users" or "big-countries"), JOIN and combine operations ("combine-two-tables"), aggregation with GROUP BY and HAVING, and window functions for ranking or running totals. The pattern is recognizable by the presence of table schemas, expected output structure, and constraints on data consistency. Drill order: start with single-table filters and basic aggregates, move to INNER and LEFT JOINs, then tackle window functions and recursive queries. The hardest variants involve consecutive logic, null handling, or multi-step transformations. That's where StealthCoder becomes your safety net, when you nail the problem structure but blank on the SQL syntax or edge case logic during the timed assessment.

Companies that hire most on database

The honest play

87 database problems. You won't drill them all. Pass anyway.

Database is one of the patterns interviews actually filter on. Memorizing every variant in a week is a fantasy. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds, no matter which database flavor lands in your live OA. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Database interview FAQ

How many Database problems should I drill before an OA?+

With 87 total problems in this pattern, aim to solve 20-30 across all difficulty tiers before your OA. Focus on the most common subtypes: joins, aggregation, and filtering. Companies like Google and TCS ask 1-2 Database problems per assessment, so depth over breadth matters.

Which company drills Database patterns the hardest?+

TCS asks 19 Database problems across their assessments, the highest count in the dataset. Google (14), Deloitte (12), and X (12) also weight them heavily. If you're targeting any of these, expect multi-table logic and window functions, not just basic SELECT statements.

How do I recognize a Database problem in an OA?+

You'll see a schema diagram or table definition, sample input rows, and an expected output table or aggregated result. The prompt asks you to write SQL, not code a data structure. Look for keywords: JOIN, GROUP BY, aggregate functions (SUM, COUNT, AVG), window functions (ROW_NUMBER, RANK), or NULL handling.

Are Database problems the hardest pattern for coding interviews?+

Not harder than advanced algorithmic patterns, but they're deceptively tricky because the logic is simple but edge cases hide in the data. Nulls, duplicates, and time-zone or date arithmetic trip up candidates who don't test thoroughly. They're common enough to tank your score if you skip them.

What's the fastest way to solve Database problems under time pressure?+

Read the schema and expected output first, not the problem text. Identify the joins and grouping logic by comparing input and output shape. Write the SELECT clause, then WHERE, then JOIN and GROUP BY. Test mentally with one or two rows. In a live OA, StealthCoder eliminates the mental testing step and syntax lookup.

Problem and frequency data sourced from public community-maintained interview-report repos. Problems and trademarks © LeetCode.