The Most Predictable Interview Section
If Power BI questions test how you build, SQL questions test how you think. The good news: analyst-level SQL interviews are remarkably predictable. They probe the same core patterns — basic queries, joins, aggregation, window functions — over and over. Prepare these and you'll walk into any analyst SQL round with confidence.
Q1. What's the difference between WHERE and HAVING?
WHERE filters rows before aggregation; HAVING filters groups after aggregation. You can't use an aggregate in WHERE (WHERE SUM(x) > 10 is invalid), but you can in HAVING. In practice: filter raw rows with WHERE for performance, use HAVING for conditions on aggregated results.
Q2. Explain the types of joins with an example.
INNER JOIN returns matching rows from both tables. LEFT JOIN returns all rows from the left table plus matches (NULLs where no match). RIGHT JOIN is the mirror. FULL OUTER JOIN returns all rows from both sides. SELF JOIN joins a table to itself (e.g., employees to managers). CROSS JOIN pairs every row with every row — rarely needed, dangerous if forgotten.
Q3. How do you find duplicate records?
Group by the columns that should be unique and count: SELECT email, COUNT(*) FROM users GROUP BY email HAVING COUNT(*) > 1. For full-row duplicates, use GROUP BY all columns or the ROW_NUMBER() OVER (PARTITION BY … ) technique to identify and optionally delete one of each.
Q4. What is the difference between a subquery and a CTE?
A subquery is a query nested inside another query (in SELECT, FROM or WHERE). A CTE (WITH clause) names an intermediate result set that you can reference, often multiple times, above the main query. CTEs are more readable for complex logic and are the modern preferred pattern for multi-step analysis.
Q5. Explain window functions and give an example.
Window functions compute values across a set of rows related to the current row without collapsing the result — unlike GROUP BY. Examples: ROW_NUMBER() OVER (PARTITION BY category ORDER BY sales DESC) to rank products within each category, or SUM(sales) OVER (PARTITION BY region ORDER BY month) for a running total.
Q6. How do you get the top 3 salaries per department?
Use a window function: WITH ranked AS (SELECT *, ROW_NUMBER() OVER (PARTITION BY dept_id ORDER BY salary DESC) AS rn FROM employees) SELECT * FROM ranked WHERE rn <= 3. This preserves ties handling options (ROW_NUMBER vs RANK) and is a classic interviewer favorite.
Q7. What's the difference between RANK, DENSE_RANK and ROW_NUMBER?
ROW_NUMBER assigns a unique sequential number (1,2,3) regardless of ties. RANK gives tied rows the same number and skips the next (1,1,3). DENSE_RANK gives tied rows the same number without skipping (1,1,2). Choose based on whether you want unique rows or meaningful ties.
Q8. What is a left join where the right key is NULL useful for?
The "LEFT JOIN … WHERE right.key IS NULL" pattern returns rows from the left table with no match in the right — perfect for finding orphaned records, customers who never ordered, or products with no sales. It's the standard anti-join technique.
Q9. How would you write a query for month-over-month growth?
Aggregate sales by month, then use LAG to reference the previous month: WITH monthly AS (SELECT DATE_TRUNC('month', order_date) AS month, SUM(amount) AS total FROM orders GROUP BY 1), growth AS (SELECT month, total, LAG(total) OVER (ORDER BY month) AS prev FROM monthly) SELECT month, total, (total – prev) / prev AS growth FROM growth. LAG/LEAD for comparisons is exactly what interviewers want to see.
Q10. What is query folding in the Power BI context?
Query folding is when Power Query pushes transformation steps back to the source database as SQL, so only the processed result is returned instead of pulling raw data into memory. It's vital for performance with large tables — and a favourite crossover question because it shows SQL awareness inside the Power BI world.
SQL interviews reward clean thinking. Write your answer in plain words first, then translate to SQL — the logic is what's being tested.
The Thinking Behind Every Answer
These ten questions share a secret: each one tests a habit, not a fact. The WHERE vs HAVING question tests whether you think about when aggregation happens. The joins question tests whether you can visualize relationships between data. The duplicates question tests whether you can express "what should be unique" precisely. The window-function questions test whether you understand rows in relation to other rows. When you answer, name the thinking: "this is an anti-join, so I'll use a LEFT JOIN with a NULL check" — that language signals someone who reasons in patterns, not someone who memorized answers.
Interviewers also watch how you handle the moment you don't know something. The professional response is to think aloud: "I'm not sure of the exact syntax, but the approach would be…" — stated logic you can reason through beats silence or a wrong confident guess. Every strong analyst has answered an unknown question by reasoning from first principles; that's the skill this round is actually testing.
How to Practice Like You're Interviewing
- Rewrite each answer in plain words before looking at the model answer.
- Type the SQL, don't just read it — muscle memory matters.
- Time yourself: a full answer in under two minutes.
- Explain your answer out loud as if the interviewer can't see the screen.
- Create your own variations: change the table names, change the question slightly, solve again.
A week of this practice, twenty minutes a day, and the SQL round becomes the round you look forward to. That's the level of calm interviewers reward — and it's exactly what mock-interview rehearsal builds in candidates before they ever sit in the real room.
One last note: interviewers love to see you take a follow-up the "wrong" way and recover. If the interviewer says "what if the data is different than you assumed?", the strongest response is to state the new assumption and reason again from there — showing adaptability, not memorization. Practising recovery beats practising perfection, and it's the quality that finally separates the answer robots from the analysts.
Master these ten questions and their patterns, and you'll notice something: the SQL round stops being a gate and becomes an opportunity to display the precise, structured thinking that every data role rewards.
Walk Into Interviews With Confidence
Join the Power BI Master Course at ₹4,999 — live classes, 4 projects, mock interviews and placement support.
100% money-back guarantee if you don’t find value in the first class
Our Top Power BI Course in India
Looking for Power BI training in a specific city? Explore our city-wise Power BI Course pages to find course information, training details, curriculum, practical learning approach, and career guidance for your location.
Leave a Reply