These are SQL questions of the kind Microsoft actually asks — the patterns reported from Microsoft's SQL screens and data/SDE interview rounds. My advice: treat this page as a mock test. Attempt every question on paper first, then reveal. If any answer surprises you, the lesson it comes from is linked right below — go read it, then come back.
Microsoft SQL concept questions
Why is it generally recommended to create an index on foreign key columns?
Asked in


Microsoft SQL query questions
The inventory table tracks stock quantity per item. Write a transaction that uses SELECT ... FOR UPDATE to lock the row for item_id = 1 before decrementing its stock by 1, so that a concurrent transaction trying to sell the same item cannot read a stale quantity and cause a lost update.
Asked in


inventory2 rows
| item_id | item_name | stock_qty |
|---|---|---|
| 1 | Wireless Mouse | 10 |
| 2 | USB-C Cable | 25 |
Given an employees table with emp_id, name, dept_id, and salary, write a query using NTILE(4) to assign each employee within their department to a salary quartile (1 = highest earners), and explain what you'd expect for a department whose employee count isn't a multiple of 4.
Asked in


employees8 rows
| emp_id | name | dept_id | salary |
|---|---|---|---|
| 1 | Alice | 10 | 100000 |
| 2 | Bob | 10 | 90000 |
| 3 | Carol | 10 | 80000 |
| 4 | David | 10 | 70000 |
| 5 | Eve | 10 | 60000 |
| 6 | Frank | 20 | 90000 |
| 7 | Grace | 20 | 80000 |
| 8 | Heidi | 20 | 70000 |
How to use this page: Microsoft rarely asks a question you've never seen — they ask standard patterns with a twist. Master the pattern in the SQL course lessons, and the twist stops mattering.
Keep practising: SQL Basics, Joins, GROUP BY & HAVING and Subqueries cover what most Microsoft SQL rounds test.

