SQL interview questions cover joins, subqueries, window functions, indexing, and query optimization. Technical interviews test both syntax knowledge and your ability to translate business requirements into efficient queries against real-world schemas.
Basic SQL Questions (25)
Cover SELECT, WHERE, GROUP BY, JOINs, and the foundational SQL syntax every backend developer and data analyst must know cold.
easy What is SQL and what is it used for?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What are the different types of SQL commands (DDL, DML, DCL, TCL)?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What is the difference between WHERE and HAVING clauses?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What is a PRIMARY KEY? How does it differ from a UNIQUE KEY?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What is a FOREIGN KEY and how does it enforce referential integrity?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What are the different types of JOINs in SQL (INNER, LEFT, RIGHT, FULL, CROSS)?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What is the difference between DELETE, TRUNCATE, and DROP?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy Explain the SELECT statement and common clauses used with it.
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What are aggregate functions in SQL (COUNT, SUM, AVG, MIN, MAX)?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What is the GROUP BY clause and how is it used?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What is the ORDER BY clause? How do you sort ascending vs descending?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What are NULL values in SQL? How do you handle them?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What is the difference between CHAR and VARCHAR data types?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What are constraints in SQL? Name the different types.
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What is a VIEW in SQL and how is it used?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What is an ALIAS in SQL and when would you use it?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy How do you use the LIKE operator for pattern matching in SQL?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What is the DISTINCT keyword and how does it differ from GROUP BY?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What is the difference between COUNT(*) and COUNT(column_name)?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy How do you retrieve the top N records in SQL (LIMIT/TOP)?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What is the IN operator and how do you use it?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What is the BETWEEN operator?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy How do you insert, update, and delete data in a table?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy How do you create a table and add/remove columns?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
easy What is the difference between SQL and NoSQL databases?
What interviewers evaluate: Basic SQL Questions
Expand and practise this question in an AI mock interview.
Intermediate SQL Questions (25)
Master subqueries, CTEs, window functions basics, normalization, transactions, and the SQL skills required for mid-level interviews.
medium What is a subquery? What are correlated vs non-correlated subqueries?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium What is the difference between UNION and UNION ALL?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium What is a CTE (Common Table Expression) and when would you use it?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium Explain the difference between RANK(), DENSE_RANK(), and ROW_NUMBER().
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium What are window functions in SQL? Give examples.
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium How do you find the second (or Nth) highest salary in a table?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium How do you find and remove duplicate rows from a table?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium What is a self-join and when would you use it?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium How does the CASE statement work in SQL?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium What is the difference between EXISTS/NOT EXISTS and IN/NOT IN?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium What is normalization? Explain the different normal forms (1NF, 2NF, 3NF, BCNF).
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium What is denormalization and when is it used?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium How do you calculate a running total or moving average in SQL?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium Explain the purpose of LAG() and LEAD() window functions.
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium What is the COALESCE function and how is it used?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium What is the MERGE (UPSERT) statement and when should it be used?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium How do you use COMMIT, ROLLBACK, and SAVEPOINT in transactions?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium What are the ACID properties of a transaction?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium How do you implement pagination in SQL?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium What is the purpose of the SQL PIVOT operator?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium How do you update one table based on values from another table?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium What is a cross join and how does it differ from an inner join?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium Explain anti-joins and how to find records in one table that are not in another.
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium What is referential integrity? How is it enforced?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
medium What are temporary tables? When should you use them?
What interviewers evaluate: Intermediate SQL Questions
Expand and practise this question in an AI mock interview.
Advanced SQL Questions (25)
Cover query plans, indexing strategies, stored procedures, triggers, materialized views, and the advanced SQL topics senior developers must know.
hard How do you optimize a slow-running query?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What is a query execution plan (EXPLAIN) and how do you interpret it?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What is the difference between clustered and non-clustered indexes?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What is a stored procedure? What are its advantages?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What is a trigger in SQL? What are the different types?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What is a materialized view and how does it differ from a regular view?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What are the different transaction isolation levels?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What is a deadlock? How do you detect and avoid deadlocks?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What is a recursive CTE and when would you use it?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard Explain database partitioning (horizontal vs vertical).
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What is database sharding and how does it differ from partitioning?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What is sargability in SQL and why does it matter for indexing?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What are the differences between OLTP and OLAP systems?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard How do you handle slowly changing dimensions (SCD Type 2)?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What is dynamic SQL? What are its advantages and risks?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What is a cursor in SQL? When would you use one?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard How do composite indexes work and how do you choose column order?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What is a covering index?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What is the WITH (NOLOCK) hint in SQL Server? When should it be used?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard How does SQL handle recursive queries?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What is lock escalation? Explain optimistic vs pessimistic locking.
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What strategies protect a web application from SQL injection?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard How do you ensure data consistency across distributed databases?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard What are the trade-offs of using indexes in SQL databases?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
hard How can you monitor query performance in a production database?
What interviewers evaluate: Advanced SQL Questions
Expand and practise this question in an AI mock interview.
Practical Query Challenges (20)
Solve real coding problems: find duplicates, calculate running totals, retrieve latest records per group, and the SQL puzzles interviewers love.
medium Write a query to find the Nth highest salary among all employees.
What interviewers evaluate: Subqueries, window functions, LIMIT/OFFSET
Expand and practise this question in an AI mock interview.
medium Write a query to find duplicate rows in a table and remove them while keeping one copy.
What interviewers evaluate: GROUP BY, HAVING, CTEs, DELETE with ROW_NUMBER
Expand and practise this question in an AI mock interview.
medium Write a query to calculate the running total of sales for each product.
What interviewers evaluate: Window functions (SUM OVER), partitioning
Expand and practise this question in an AI mock interview.
medium Find employees whose salary is greater than the average salary in their department.
What interviewers evaluate: Correlated subqueries, window functions
Expand and practise this question in an AI mock interview.
medium Write a query to retrieve the latest record per user/group.
What interviewers evaluate: ROW_NUMBER(), PARTITION BY, subqueries
Expand and practise this question in an AI mock interview.
medium Calculate month-over-month change in revenue.
What interviewers evaluate: LAG/LEAD, date functions, window functions
Expand and practise this question in an AI mock interview.
medium Write a query to find all employees without a manager (orphan rows).
What interviewers evaluate: LEFT JOIN + IS NULL, NOT EXISTS
Expand and practise this question in an AI mock interview.
medium Compute a funnel conversion rate (visit -> signup -> purchase).
What interviewers evaluate: CASE, conditional aggregation, CTEs
Expand and practise this question in an AI mock interview.
medium Write a query to find customers who haven't ordered in the last 60 days (churned).
What interviewers evaluate: Date arithmetic, LEFT JOIN, NOT EXISTS
Expand and practise this question in an AI mock interview.
medium Sessionize user events using a 30-minute inactivity window.
What interviewers evaluate: LAG, CASE, window functions, date math
Expand and practise this question in an AI mock interview.
medium Compute D1/D7/D30 retention cohorts.
What interviewers evaluate: Self-joins, date functions, GROUP BY
Expand and practise this question in an AI mock interview.
medium Write a query to detect overlapping date ranges (e.g., subscriptions).
What interviewers evaluate: Self-join, date comparison, CASE
Expand and practise this question in an AI mock interview.
medium Find the top N rows per group (e.g., top 3 products per category).
What interviewers evaluate: ROW_NUMBER() PARTITION BY, subqueries
Expand and practise this question in an AI mock interview.
medium Calculate year-over-year sales growth by product or region.
What interviewers evaluate: LAG, date functions, percentage calculation
Expand and practise this question in an AI mock interview.
medium Write a query to deduplicate rows and keep only the latest record.
What interviewers evaluate: ROW_NUMBER(), DELETE with CTE, PARTITION BY
Expand and practise this question in an AI mock interview.
medium Compute A/B test conversion uplift from experiment data.
What interviewers evaluate: Conditional aggregation, CASE, GROUP BY
Expand and practise this question in an AI mock interview.
medium Write a query to find the longest continuous login streak per user.
What interviewers evaluate: LAG, ROW_NUMBER, date difference technique
Expand and practise this question in an AI mock interview.
medium Calculate customer lifetime value (LTV) and bucket users by tier.
What interviewers evaluate: SUM, CASE, GROUP BY, subqueries
Expand and practise this question in an AI mock interview.
medium Write a query that dynamically pivots rows into columns.
What interviewers evaluate: PIVOT, dynamic SQL, CASE with aggregation
Expand and practise this question in an AI mock interview.
medium Flag outliers based on z-score calculation.
What interviewers evaluate: AVG, STDDEV, window functions, CASE
Expand and practise this question in an AI mock interview.
Database Design Questions (15)
Cover schema design, normalization vs denormalization, indexing strategy, partitioning, sharding, and the data modeling decisions that affect performance.
easy What is normalization? Explain 1NF, 2NF, 3NF, and BCNF.
What interviewers evaluate: Database Design Questions
Expand and practise this question in an AI mock interview.
easy What is denormalization and when would you use it?
What interviewers evaluate: Database Design Questions
Expand and practise this question in an AI mock interview.
medium How do you implement one-to-one, one-to-many, and many-to-many relationships?
What interviewers evaluate: Database Design Questions
Expand and practise this question in an AI mock interview.
medium What is a composite key? When would you use one?
What interviewers evaluate: Database Design Questions
Expand and practise this question in an AI mock interview.
medium Define candidate key, alternate key, and surrogate key.
What interviewers evaluate: Database Design Questions
Expand and practise this question in an AI mock interview.
medium How do you design a database schema for high scalability?
What interviewers evaluate: Database Design Questions
Expand and practise this question in an AI mock interview.
hard What is a star schema vs snowflake schema in data warehousing?
What interviewers evaluate: Database Design Questions
Expand and practise this question in an AI mock interview.
medium What is the difference between OLTP and OLAP database design?
What interviewers evaluate: Database Design Questions
Expand and practise this question in an AI mock interview.
medium How do you enforce referential integrity in a database?
What interviewers evaluate: Database Design Questions
Expand and practise this question in an AI mock interview.
medium What are the best practices for ensuring data integrity?
What interviewers evaluate: Database Design Questions
Expand and practise this question in an AI mock interview.
hard What is an ER diagram and how do you use it in schema design?
What interviewers evaluate: Database Design Questions
Expand and practise this question in an AI mock interview.
hard What is data redundancy and how does normalization address it?
What interviewers evaluate: Database Design Questions
Expand and practise this question in an AI mock interview.
hard What is a slowly changing dimension (SCD)? Describe Type 1, 2, and 3.
What interviewers evaluate: Database Design Questions
Expand and practise this question in an AI mock interview.
hard How do you design SQL tables for a star schema data model?
What interviewers evaluate: Database Design Questions
Expand and practise this question in an AI mock interview.
hard What is a tablespace and how does it relate to database storage?
What interviewers evaluate: Database Design Questions
Expand and practise this question in an AI mock interview.
Performance & Optimization Questions (15)
Learn how to read EXPLAIN plans, optimize slow queries, choose the right indexes, and diagnose database performance issues in production.
easy How do you optimize a slow-running SQL query?
What interviewers evaluate: Performance & Optimization Questions
Expand and practise this question in an AI mock interview.
easy What is an index? What are the different types (clustered, non-clustered, composite, covering)?
What interviewers evaluate: Performance & Optimization Questions
Expand and practise this question in an AI mock interview.
easy How does indexing improve query performance? What are the trade-offs?
What interviewers evaluate: Performance & Optimization Questions
Expand and practise this question in an AI mock interview.
easy What is a query execution plan and how do you read it?
What interviewers evaluate: Performance & Optimization Questions
Expand and practise this question in an AI mock interview.
medium What is sargability and how do non-sargable conditions hurt performance?
What interviewers evaluate: Performance & Optimization Questions
Expand and practise this question in an AI mock interview.
medium What are the considerations for indexing very large tables?
What interviewers evaluate: Performance & Optimization Questions
Expand and practise this question in an AI mock interview.
hard How do you perform bulk inserts efficiently?
What interviewers evaluate: Performance & Optimization Questions
Expand and practise this question in an AI mock interview.
hard What are the trade-offs of indexing vs denormalization?
What interviewers evaluate: Performance & Optimization Questions
Expand and practise this question in an AI mock interview.
easy What is database partitioning and how does it improve performance?
What interviewers evaluate: Performance & Optimization Questions
Expand and practise this question in an AI mock interview.
medium How do you optimize JOIN operations on large tables?
What interviewers evaluate: Performance & Optimization Questions
Expand and practise this question in an AI mock interview.
easy What are materialized views and when do they help performance?
What interviewers evaluate: Performance & Optimization Questions
Expand and practise this question in an AI mock interview.
hard What causes double counting in joins and how can it be prevented?
What interviewers evaluate: Performance & Optimization Questions
Expand and practise this question in an AI mock interview.
medium How do you handle performance tuning in production SQL databases?
What interviewers evaluate: Performance & Optimization Questions
Expand and practise this question in an AI mock interview.
hard What is the difference between vertical and horizontal scaling in databases?
What interviewers evaluate: Performance & Optimization Questions
Expand and practise this question in an AI mock interview.
hard How do you compare performance between two SQL queries?
What interviewers evaluate: Performance & Optimization Questions
Expand and practise this question in an AI mock interview.
Top 15 Recommended for MockIF Page (8)
Start here. The 15 most impactful SQL questions covering JOINs, subqueries, window functions, indexing, and ACID properties.
easy What are the different types of JOINs in SQL? Explain INNER, LEFT, RIGHT, FULL, and CROSS JOIN with examples.
What interviewers evaluate: Top 15 Recommended for MockIF Page
Expand and practise this question in an AI mock interview.
easy What is the difference between WHERE and HAVING?
What interviewers evaluate: Top 15 Recommended for MockIF Page
Expand and practise this question in an AI mock interview.
medium What is a subquery? Explain correlated vs non-correlated subqueries.
What interviewers evaluate: Top 15 Recommended for MockIF Page
Expand and practise this question in an AI mock interview.
medium What is a CTE (Common Table Expression) and when would you use one?
What interviewers evaluate: Top 15 Recommended for MockIF Page
Expand and practise this question in an AI mock interview.
medium Write a query to find the Nth highest salary in a table.
What interviewers evaluate: Top 15 Recommended for MockIF Page
Expand and practise this question in an AI mock interview.
medium What are the ACID properties of a database transaction?
What interviewers evaluate: Top 15 Recommended for MockIF Page
Expand and practise this question in an AI mock interview.
hard What are the different transaction isolation levels in SQL?
What interviewers evaluate: Top 15 Recommended for MockIF Page
Expand and practise this question in an AI mock interview.
hard What is database partitioning and sharding? When would you use each?
What interviewers evaluate: Top 15 Recommended for MockIF Page
Expand and practise this question in an AI mock interview.
Easy Level (16)
Build SQL fundamentals with easy-level coding problems covering SELECT, GROUP BY, simple JOINs, and the basic operations every SQL interview tests.
easy Histogram of Tweets: count tweets per user in a given time period
What interviewers evaluate: GROUP BY, COUNT, date filtering
Expand and practise this question in an AI mock interview.
easy Data Science Skills: find candidates with all 3 required skills
What interviewers evaluate: GROUP BY, HAVING, COUNT
Expand and practise this question in an AI mock interview.
easy Page With No Likes: find pages with zero likes
What interviewers evaluate: LEFT JOIN, IS NULL / NOT EXISTS
Expand and practise this question in an AI mock interview.
easy Unfinished Parts: find parts that were not finished in manufacturing
What interviewers evaluate: WHERE IS NULL, filtering
Expand and practise this question in an AI mock interview.
easy Laptop vs. Mobile Viewership: count views by device type
What interviewers evaluate: CASE, conditional aggregation
Expand and practise this question in an AI mock interview.
easy Average Post Hiatus: find average days between posts per user
What interviewers evaluate: LAG, date diff, aggregation
Expand and practise this question in an AI mock interview.
easy Teams Power Users: find top 2 users by message count per team
What interviewers evaluate: ROW_NUMBER, PARTITION BY
Expand and practise this question in an AI mock interview.
easy Average Review Ratings: avg stars per product per month
What interviewers evaluate: GROUP BY, AVG, date extraction
Expand and practise this question in an AI mock interview.
easy Well Paid Employees: find employees earning more than their manager
What interviewers evaluate: Self-join, salary comparison
Expand and practise this question in an AI mock interview.
easy Final Account Balance: calculate running balance from transactions
What interviewers evaluate: SUM, CASE, aggregation
Expand and practise this question in an AI mock interview.
easy App Click-through Rate (CTR): calculate CTR from impressions and clicks
What interviewers evaluate: CASE, SUM, division
Expand and practise this question in an AI mock interview.
easy Second Day Confirmation: users who confirmed on the day after signup
What interviewers evaluate: JOIN, date arithmetic
Expand and practise this question in an AI mock interview.
easy IBM db2 Product Analytics: count unique queries per employee
What interviewers evaluate: COUNT DISTINCT, GROUP BY
Expand and practise this question in an AI mock interview.
easy Cards Issued Difference: max minus min cards issued per card name
What interviewers evaluate: GROUP BY, MAX, MIN
Expand and practise this question in an AI mock interview.
easy Compressed Mean: weighted average from frequency table
What interviewers evaluate: SUM with multiplication, CAST
Expand and practise this question in an AI mock interview.
easy Pharmacy Analytics Parts 1-3: drug profitability analysis
What interviewers evaluate: ORDER BY, aggregation, TOP N
Expand and practise this question in an AI mock interview.
Medium Level (16)
Practice medium-difficulty SQL coding problems covering subqueries, multi-table JOINs, conditional logic, and the patterns that show up in technical screens.
medium User's Third Transaction: find each user's third purchase
What interviewers evaluate: ROW_NUMBER, PARTITION BY, filtering
Expand and practise this question in an AI mock interview.
medium Second Highest Salary: find 2nd highest salary in a table
What interviewers evaluate: DENSE_RANK or subquery, edge cases
Expand and practise this question in an AI mock interview.
medium Sending vs. Opening Snaps: time spent sending vs opening by age group
What interviewers evaluate: CASE, SUM, JOIN, percentage calc
Expand and practise this question in an AI mock interview.
medium Tweets' Rolling Averages: 3-day rolling avg of tweets per user
What interviewers evaluate: Window SUM/COUNT with ROWS BETWEEN
Expand and practise this question in an AI mock interview.
medium Highest-Grossing Items: top 2 products by revenue per category
What interviewers evaluate: RANK, PARTITION BY, aggregation
Expand and practise this question in an AI mock interview.
medium Top Three Salaries: top 3 earners per department
What interviewers evaluate: DENSE_RANK, PARTITION BY
Expand and practise this question in an AI mock interview.
medium Signup Activation Rate: percentage of signups that activated
What interviewers evaluate: LEFT JOIN, conditional aggregation
Expand and practise this question in an AI mock interview.
medium Spotify Streaming History: identify songs with increasing play counts
What interviewers evaluate: LAG, window functions, trend detection
Expand and practise this question in an AI mock interview.
medium Supercloud Customer: customers who bought from every product category
What interviewers evaluate: GROUP BY, HAVING COUNT = total categories
Expand and practise this question in an AI mock interview.
medium FAANG Stock Min-Max: min and max open prices per month
What interviewers evaluate: GROUP BY, date truncation, MIN/MAX
Expand and practise this question in an AI mock interview.
medium Best-Selling Product: identify top product by total revenue
What interviewers evaluate: Aggregation, ranking
Expand and practise this question in an AI mock interview.
medium User Shopping Sprees: find users with 3+ consecutive purchase days
What interviewers evaluate: LAG/LEAD, consecutive date detection
Expand and practise this question in an AI mock interview.
medium Histogram of Users and Purchases: distribution of purchase counts
What interviewers evaluate: Subquery, GROUP BY, COUNT
Expand and practise this question in an AI mock interview.
medium Odd and Even Measurements: separate odd vs even numbered measurements per day
What interviewers evaluate: ROW_NUMBER, CASE, conditional aggregation
Expand and practise this question in an AI mock interview.
medium Swapped Food Delivery: detect swapped delivery orders
What interviewers evaluate: Self-join or LEAD/LAG, pair detection
Expand and practise this question in an AI mock interview.
medium Compressed Mode: find statistical mode from frequency distribution
What interviewers evaluate: Ranking within aggregation
Expand and practise this question in an AI mock interview.
Window Function Deep Dive (11)
Master ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD, PARTITION BY, and the window function patterns that solve analytical problems elegantly.
medium Summarize total sales revenue per product line using SUM() OVER(PARTITION BY)
What interviewers evaluate: Window Function Deep Dive
Expand and practise this question in an AI mock interview.
medium Calculate a running total using SUM() with OVER() and ORDER BY
What interviewers evaluate: Window Function Deep Dive
Expand and practise this question in an AI mock interview.
medium Use NTILE() to divide rows into N equal groups (quartiles, deciles)
What interviewers evaluate: Window Function Deep Dive
Expand and practise this question in an AI mock interview.
medium Calculate average delay between user signup and their 2nd ride
What interviewers evaluate: Window Function Deep Dive
Expand and practise this question in an AI mock interview.
hard Identify repeated payments at same merchant with same card within 10 minutes
What interviewers evaluate: Window Function Deep Dive
Expand and practise this question in an AI mock interview.
hard Explain the FRAME clause (ROWS BETWEEN) in window functions with examples
What interviewers evaluate: Window Function Deep Dive
Expand and practise this question in an AI mock interview.
hard How do you optimize queries with multiple window functions on large datasets?
What interviewers evaluate: Window Function Deep Dive
Expand and practise this question in an AI mock interview.
hard Find percentage of buyers who bought AirPods directly after purchasing an iPhone
What interviewers evaluate: Window Function Deep Dive
Expand and practise this question in an AI mock interview.
medium Display employee salary alongside department average using window function
What interviewers evaluate: Window Function Deep Dive
Expand and practise this question in an AI mock interview.
medium Identify best-selling item by revenue for each month
What interviewers evaluate: Window Function Deep Dive
Expand and practise this question in an AI mock interview.
hard Compare driver churn rates year-over-year, label as increase/decrease/no change
What interviewers evaluate: Window Function Deep Dive
Expand and practise this question in an AI mock interview.
Facebook (3)
Practice the SQL coding problems Facebook (Meta) is known to ask, covering analytics, growth metrics, and complex multi-table queries.
easy Return total number of comments received per user in past 30 days
What interviewers evaluate: Date filtering, aggregation
Expand and practise this question in an AI mock interview.
medium Calculate share/percentage of active users from the US with 'open' status
What interviewers evaluate: Conditional filtering, percentage calc
Expand and practise this question in an AI mock interview.
hard Compare total comments by country between Dec 2019 and Jan 2020, identify improved rankings
What interviewers evaluate: DENSE_RANK, joins, comparative analysis
Expand and practise this question in an AI mock interview.
Amazon (3)
Practice the SQL coding problems Amazon asks, covering inventory analytics, customer metrics, and the data scenarios common in retail and e-commerce.
easy Find total cost of each customer's orders (output customer id, name, total)
What interviewers evaluate: JOINs, SUM, GROUP BY
Expand and practise this question in an AI mock interview.
medium Identify returning users who made a second purchase within 1-7 days of first purchase
What interviewers evaluate: Date range filtering, self-join
Expand and practise this question in an AI mock interview.
hard Determine which users made additional purchases due to marketing campaign success
What interviewers evaluate: Complex conditional logic, edge cases
Expand and practise this question in an AI mock interview.
Google (3)
Practice Google's SQL interview problems covering search analytics, user behavior queries, and the complex aggregations Google data engineers handle daily.
easy Find total AdWords earnings for each business type
What interviewers evaluate: GROUP BY, SUM
Expand and practise this question in an AI mock interview.
medium Find number of emails received by each user under each built-in email label (Promotion, Social, Shopping)
What interviewers evaluate: JOINs, CASE/conditional aggregation
Expand and practise this question in an AI mock interview.
medium Rank users by email activity with specific ordering and tiebreaker requirements
What interviewers evaluate: Window functions, ranking
Expand and practise this question in an AI mock interview.
Advanced SQL Concepts (18)
Cover trigger sequencing, transaction isolation, deadlocks, locking strategies, and the advanced concepts required for senior database roles.
medium What is PL/SQL and how does it differ from standard SQL?
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
hard What is a recursive stored procedure? When would you use one?
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
hard Explain the difference between @@IDENTITY, SCOPE_IDENTITY(), and IDENT_CURRENT
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
hard What is a fill factor in an index? When does a page split occur?
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
hard What is RAID and how does it relate to database performance?
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
hard What are the different ways of moving data between databases in SQL Server?
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
hard What is BCP (Bulk Copy Program) utility in SQL Server?
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
hard How can you raise custom errors from a stored procedure?
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
hard If we have multiple AFTER triggers on a table, how do we define the sequence?
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
medium What is collation and what are the different types of collation sensitivity?
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
hard How do you alter a table to make an existing column an identity column?
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
medium How do you fetch alternate (odd/even numbered) records from a table?
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
medium How do you fetch common records from two tables without using JOIN?
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
medium What is the difference between local and global temporary tables (# vs ##)?
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
medium What is the difference between user-defined functions and stored procedures?
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
medium What are scalar functions vs table-valued functions?
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
hard What is DBCC and what are its commonly used commands?
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
hard What is a composite index with 3 columns? Will it be used if you only provide 2 columns in WHERE?
What interviewers evaluate: Advanced SQL Concepts
Expand and practise this question in an AI mock interview.
Advanced Practical Challenges (10)
Tackle expert-level SQL problems combining CTEs, window functions, date manipulation, and complex business logic into maintainable production queries.
hard Return the top 3 creators in the US for the last full week, with total minutes and week-over-week comparison
What interviewers evaluate: CTE, LAG, DENSE_RANK, date truncation
Expand and practise this question in an AI mock interview.
medium Find all employees whose DOB is between 01/01/1960 and 31/12/1975, grouped by gender
What interviewers evaluate: Date filtering, GROUP BY, COUNT
Expand and practise this question in an AI mock interview.
easy Find employees whose name contains "Joe" regardless of case (JOE, Joe, joe)
What interviewers evaluate: LOWER/UPPER, LIKE, case-insensitive search
Expand and practise this question in an AI mock interview.
easy Create an empty table with the same schema as an existing table
What interviewers evaluate: CREATE TABLE AS SELECT, WHERE 1=0
Expand and practise this question in an AI mock interview.
medium Write a query where students' marks are greater than the average marks of all students
What interviewers evaluate: Subquery with AVG, comparison
Expand and practise this question in an AI mock interview.
medium Find all employees who are also managers (self-referencing hierarchy)
What interviewers evaluate: Self-join, EXISTS
Expand and practise this question in an AI mock interview.
medium Find candidates who have ALL required skills (not just some)
What interviewers evaluate: GROUP BY, HAVING COUNT, set completeness
Expand and practise this question in an AI mock interview.
hard Detect users with 3+ consecutive days of activity (streak detection)
What interviewers evaluate: LAG/LEAD, ROW_NUMBER date diff technique
Expand and practise this question in an AI mock interview.
medium Calculate 3-day rolling average of a metric per user
What interviewers evaluate: AVG with ROWS BETWEEN, PARTITION BY
Expand and practise this question in an AI mock interview.
hard Identify customers who purchased from EVERY product category (division query)
What interviewers evaluate: Relational division, GROUP BY HAVING
Expand and practise this question in an AI mock interview.