All 135 questions
What are SQL joins, and which rows do INNER, LEFT, RIGHT, and FULL OUTER JOIN return?
Asked in 46 of 612 interviews · last asked Oct 22 · Concept · Junior
Show answer
SQL joins combine rows from two tables using a match condition. INNER JOIN returns only matching row pairs. LEFT and RIGHT JOIN return matches plus every unmatched row from the left or right table, respectively, with NULLs for the missing side. FULL OUTER JOIN returns matches and unmatched rows from both tables, with NULLs for the missing side.
- The join condition, usually written with ON, determines which row pairs match.
- LEFT preserves every left-side row; RIGHT preserves every right-side row.
- A row with multiple matches appears once for each matching pair.
- Support for RIGHT JOIN and FULL OUTER JOIN depends on the database and version.
What the interviewer checks: The interviewer checks whether you understand matching rows, preserved rows, and NULLs for missing matches.
Common mistake (in 10 of 25 reviewed answers): Many answers forget that LEFT and RIGHT JOIN keep every row from their preserved side, filling missing opposite-side columns with NULLs.
Other ways it was asked
- “What is the difference between an inner join and a left join?”
- “What is the difference between INNER JOIN, LEFT JOIN, and FULL OUTER JOIN?”
- “What types of joins are available in SQL?”
How do WHERE and HAVING differ, and can you use both in one query?
Asked in 23 of 612 interviews · last asked Oct 15 · Concept · Junior
Show answer
WHERE filters individual rows before grouping and aggregation. HAVING filters groups after aggregation, so it can filter results such as COUNT or SUM. You can use both in one query: WHERE limits the input rows, and HAVING limits the resulting groups.
- WHERE cannot directly filter aggregate results from the same query level.
- HAVING can filter aggregate results, even when those results are not in SELECT.
- With aggregation, HAVING can work without GROUP BY, treating the input as one group.
SQLSELECT department_id, COUNT(*) AS employee_count FROM employees WHERE salary > 50000 GROUP BY department_id HAVING COUNT(*) >= 5;What the interviewer checks: The interviewer is checking whether you understand row filtering, group filtering, and their logical order.
Common mistake (in 5 of 10 reviewed answers): Many answers forget that WHERE filters rows before aggregation, while HAVING filters groups after aggregation.
Other ways it was asked
- “What is the difference between WHERE and HAVING?”
- “What is the difference between WHERE and HAVING in SQL?”
- “What is the difference between WHERE and HAVING, and when would you use each?”
What does UNION do, and how does it differ from UNION ALL?
Asked in 10 of 612 interviews · last asked Oct 7 · Concept · Junior
Show answer
UNION combines rows from multiple query results and removes duplicate rows. UNION ALL combines them but keeps duplicates. Use UNION when you need unique rows; use UNION ALL when duplicates are allowed or cannot occur, since it avoids duplicate removal.
- Each query must return the same number of columns, with compatible types in matching positions.
- UNION removes duplicates based on the whole row, not just one column.
- UNION ALL usually runs faster because it does not remove duplicates.
- Neither guarantees row order; use a final ORDER BY when order matters.
What the interviewer checks: The interviewer is checking whether you understand duplicate handling, compatible query results, and the performance trade-off.
Other ways it was asked
- “What is the difference between UNION and UNION ALL?”
- “What is the difference between UNION and UNION ALL in SQL?”
- “Explain the difference between UNION and UNION ALL. When would you use each?”
What are aggregate functions? Can you give an example?
Asked in 6 of 612 interviews · last asked Sep 9 · Concept · Junior
Other ways it was asked
- “What are aggregate functions?”
- “What are aggregate functions in SQL?”
- “What is an aggregate function, and can you name a few commonly used aggregate functions in MySQL?”
What does GROUP BY do in SQL, and when would you use it?
Asked in 4 of 612 interviews · last asked Aug 25 · Concept · Junior
Other ways it was asked
- “When is GROUP BY used in SQL?”
- “What is a SQL GROUP BY clause?”
- “What does the SQL GROUP BY clause do?”
What is a self-join, and when would you use one?
Asked in 2 of 612 interviews · last asked Sep 16 · Concept · Junior
Other ways it was asked
- “What is a SQL self-join, and when would you use one?”
- “What is the use of a self join?”
Write a SQL query that joins the Users and Orders tables and counts orders.
Asked in 2 of 612 interviews · last asked Jul 16 · Write code · Junior
Other ways it was asked
- “Given users and orders tables, how would you structure them and write a query to count orders per user?”
What is a WHERE clause?
Asked in 2 of 612 interviews · last asked Sep 8 · Concept · Junior
Other ways it was asked
- “What is the purpose of the WHERE clause in SQL?”
What is the purpose of HAVING in SQL?
Asked in 2 of 612 interviews · last asked Oct 11 · Concept · Junior
Other ways it was asked
- “When do we use the HAVING clause in SQL?”
How would you query the customer, product, and sales tables to find customers who bought an iPad?
Asked once · last asked Sep 21 · Write code · Junior
Write an SQL query to find claims paid $500, submitted by providers flagged as IDIS in the last 60 days.
Asked once · last asked Oct 13 · Write code · Mid-level
Other ways it was asked
- “Write an SQL query to find claims paid exactly $500 in the last 60 days and submitted by providers flagged as IDIS.”
- “Write an SQL query to find high-risk claims paid at $500 in the last 60 days, submitted by providers flagged as IDIS.”
How does SOQL handle object relationships differently from standard SQL joins?
Asked once · last asked Aug 14 · Concept · Mid-level
Other ways it was asked
- “How does SOQL handle object relationships differently from standard SQL joins, and briefly, what's the difference between an inner join and a left join?”
For a one-to-many relationship between two tables, which SQL join would you use to get the same results as Power BI?
Asked once · last asked Aug 28 · Concept · Mid-level
How would you find the records common to two sales tables in SQL?
Asked once · last asked Sep 16 · Write code · Junior
Other ways it was asked
- “How would you find the records common to two tables in SQL?”
Write a SQL query to list employees in Agra earning between 10,000 and 20,000.
Asked once · last asked Oct 11 · Write code · Junior
How would you query for users who are deny-listed and have attempted a booking, regardless of whether the booking was accepted?
Asked once · last asked Apr 15 · Write code · Mid-level
How does the $lookup operator work in MongoDB, and how is it similar to joins between SQL tables?
Asked once · last asked Apr 16 · Concept · Mid-level
Do SQL tables need a declared relationship to be joined?
Asked once · last asked Apr 27 · Concept · Mid-level
Can you join SQL tables that have no foreign-key relationship?
Asked once · last asked Apr 27 · Concept · Mid-level
How would you use SQL to investigate differences in sales and margins between two regions?
Asked once · last asked May 10 · Tooling · Mid-level
You have two tables: Customers (customer ID, name) and Orders (order ID, customer ID, order date, amount). How would you write a SQL query to list each customer and the total amount they have spent, including customers who have not placed any orders?
Asked once · last asked May 18 · Write code · Junior
Could you explain the difference between GROUP BY and DISTINCT in SQL, and give an example where GROUP BY with an aggregate function is necessary and DISTINCT alone would not be sufficient?
Asked once · last asked May 18 · Concept · Junior
Given a transactions table with columns for ID, user ID, transaction date, and amount, how would you write a SQL query to find each user's maximum transaction amount and number of transactions? Could you also explain how your query works?
Asked once · last asked May 18 · Write code · Junior
If parent and child records can arrive independently, how would you build a database framework or report to identify child records that have no corresponding parent?
Asked once · last asked May 19 · Scenario · Mid-level
Write an SQL query to find employee names that appear more than once and show how many times each name occurs.
Asked once · last asked May 22 · Write code · Junior
How would you perform a set-based operation to compare two datasets?
Asked once · last asked Jun 9 · Concept · Senior
Given a college database, what SQL query would you write to get the average grade?
Asked once · last asked Jun 11 · Write code · Junior
How would you count the number of students who received a particular grade?
Asked once · last asked Jun 11 · Write code · Junior
Write an SQL query to find products with stock less than 10.
Asked once · last asked Jun 20 · Write code · Junior
What HAVING condition would you use to identify duplicate employer IDs in a SQL query?
Asked once · last asked Jun 24 · Write code · Mid-level
How do grouping and aggregation calculate the average survival rate for each passenger class?
Asked once · last asked Jul 17 · Concept · Junior
If asked to implement CRUD operations for a products table and report the best-selling products this month, how would you approach it?
Asked once · last asked Jul 17 · Scenario · Mid-level
Write a SQL query to count occurrences of false tags in a specified column across a database.
Asked once · last asked Jul 18 · Write code · Junior
Other ways it was asked
- “Write a SQL query to count how many times each distinct value appears in a specified column.”
How would you query the number of people born on each date and return only dates with more than three people?
Asked once · last asked Jul 23 · Write code · Junior
What query would you write to find a medication using its aliases?
Asked once · last asked Jul 24 · Write code · Mid-level
Other ways it was asked
- “What query would you run to find an example medication using its aliases?”
Given users and transactions tables, explain how you would find users who signed up in the last 30 days but have not made a transaction.
Asked once · last asked Jul 25 · Write code · Junior
Write a query to fetch the five most recent payment records from a table called `payments`, ordered by creation time.
Asked once · last asked Aug 14 · Write code · Junior
What is the difference between group by and roll up?
Asked once · last asked Aug 14 · Concept · Mid-level
What does a right anti join return?
Asked once · last asked Aug 14 · Concept · Mid-level
How does a MERGE INTO operation determine whether a source row matches one or multiple target rows?
Asked once · last asked Aug 14 · Concept · Senior
Given an `employee` table, what SQL query would you use to get the number of employees in each department?
Asked once · last asked Aug 14 · Write code · Junior
How would you implement a scalable automated check in SQL, Spark, or Pandas to verify that every feature’s event time equals the label cutoff time for its entity and report violations?
Asked once · last asked Aug 19 · Write code · Senior
Can you write a SQL query to give the employee names earning more than their managers?
Asked once · last asked Aug 19 · Write code · Mid-level
Can you explain the different types of SQL joins and give a practical use case for a window function?
Asked once · last asked Aug 20 · Concept · Mid-level
Other ways it was asked
- “Walk me through the different types of SQL joins and a real case where you used a window function.”
Given two tables, how would you determine the result of a join and choose the appropriate join type?
Asked once · last asked Aug 20 · Concept · Junior
How do you determine how many rows each type of join will return for two tables?
Asked once · last asked Aug 20 · Concept · Mid-level
How would you write a SQL query to join three tables and retain rows even when matching records are missing from one or more tables?
Asked once · last asked Aug 22 · Write code · Mid-level
How do Power BI relationship cardinalities relate to SQL join types?
Asked once · last asked Aug 28 · Concept · Mid-level
How would you write SQL to find the distinct records in a table?
Asked once · last asked Aug 31 · Write code · Junior
Write SQL to retrieve the 10 highest sales from a sales table.
Asked once · last asked Sep 1 · Write code · Junior
How would you write a SQL query to calculate healthcare revenue for July and August?
Asked once · last asked Sep 3 · Write code · Mid-level
Write an SQL query that joins two tables and uses WHERE, GROUP BY, and HAVING.
Asked once · last asked Sep 7 · Write code · Junior
How would you write a SQL query to identify the lots with the highest breakage rates over the last 30 days, using lot and loss-record tables?
Asked once · last asked Sep 9 · Write code · Junior
What is a cross join, and when would you use one?
Asked once · last asked Sep 9 · Concept · Junior
Which SQL clause groups rows for aggregate calculations?
Asked once · last asked Sep 9 · Concept · Junior
Which SQL clause filters grouped results?
Asked once · last asked Sep 9 · Concept · Junior
Why can filtering rows before aggregation make a percentage calculation incorrect?
Asked once · last asked Sep 9 · Concept · Mid-level
Write a SQL query that lists each employee's floor access, showing all floor numbers for employees with multiple floors and the single floor number otherwise.
Asked once · last asked Sep 10 · Write code · Junior
Can you write a SELECT statement using the Employee and Department tables, joining them on department number and selecting all columns from both tables?
Asked once · last asked Sep 14 · Write code · Junior
Write a SQL query to get employee ID, employee name, manager name, department name, and salary.
Asked once · last asked Sep 15 · Write code · Mid-level
What is a SQL WHERE clause, and what different operators do you use with it?
Asked once · last asked Sep 16 · Concept · Junior
What are SQL set operators, and which set operators do you use?
Asked once · last asked Sep 16 · Concept · Junior
How do you use data aggregation and JOINs in SQL?
Asked once · last asked Sep 16 · Concept · Junior
How would you write a SQL query to calculate average spend per customer grouped by quarter or another time period?
Asked once · last asked Sep 17 · Write code · Mid-level
How would you calculate the average monthly spend for each plan tier?
Asked once · last asked Sep 18 · Write code · Junior
How would you count companies with more than five automations and fewer than 20 dashboards?
Asked once · last asked Sep 18 · Write code · Junior
At what point in SQL's logical query processing order is the WHERE condition evaluated?
Asked once · last asked Sep 18 · Concept · Mid-level
How would you find the five managers with the highest employee counts in SQL?
Asked once · last asked Sep 18 · Write code · Mid-level
How would you write a query to return IND first and then the rest of the countries in ascending order?
Asked once · last asked Sep 18 · Write code · Junior
How would you write a SQL query to list all employees while displaying the department name only for employees in the IT department?
Asked once · last asked Sep 21 · Write code · Junior
How would you join the product, customer, and sales tables?
Asked once · last asked Sep 21 · Write code · Junior
When joining customer and sales tables, how would you choose between an INNER JOIN and including customers with no matching sales?
Asked once · last asked Sep 21 · Concept · Junior
Give an example of a complex SQL query and explain the tables involved, joins, filters, aggregations, and the business problem it solves.
Asked once · last asked Sep 23 · Behavioral · Senior
Other ways it was asked
- “Can you give me one complex SQL query you personally wrote and explain the tables involved, joins, filters, aggregations, and the business problem it solved?”
Write a SQL query that returns the total successful transaction amount for each customer.
Asked once · last asked Sep 23 · Write code · Junior
Write a SQL query to list all orders and their order detail records.
Asked once · last asked Sep 25 · Write code · Junior
Write a SQL query to find all orders that have no matching records in the order detail table.
Asked once · last asked Sep 25 · Write code · Junior
Write a SQL query to find all students who attended at least one exam.
Asked once · last asked Sep 25 · Write code · Junior
When joining five tables, how would you filter out rows with a particular status before the join?
Asked once · last asked Sep 25 · Scenario · Mid-level
How would you implement date-based filtering in an application?
Asked once · last asked Sep 27 · Scenario · Mid-level
Write a SQL query to find all soft-deleted rows from the last seven days.
Asked once · last asked Sep 28 · Write code · Junior
Write a T-SQL query to identify the top five most frequent error codes from a healthcare integration logs table, including the count of occurrences for each error code. Assume the table has columns error code and timestamp.
Asked once · last asked Sep 29 · Write code · Mid-level
What rows does a `LEFT JOIN` return, including rows without a matching record in the other table?
Asked once · last asked Sep 29 · Concept · Junior
How would you write a SQL query to return total sales amount per region for the last 90 days?
Asked once · last asked Sep 29 · Write code · Mid-level
Write a SQL query to find all questions that have both the PHP and Laravel tags.
Asked once · last asked Oct 1 · Write code · Mid-level
Write a SQL query to select all users who registered within the last year.
Asked once · last asked Oct 1 · Write code · Junior
If someone sums distinct farm counts across months and compares that with an annual total, how would you explain the difference and provide the correct annual measure?
Asked once · last asked Oct 1 · Concept · Mid-level
If a farm is served in January and February and receives service twice during the year, how should the monthly figures and annual total be calculated?
Asked once · last asked Oct 1 · Scenario · Mid-level
How would you query two datasets to exclude inactive users and return the five users with the highest spending?
Asked once · last asked Oct 8 · Write code · Mid-level
If we need active users with their last order date but must include users with no orders, what join and aggregate would you use?
Asked once · last asked Oct 8 · Write code · Mid-level
Why can't aggregate functions be used directly in a WHERE clause to filter grouped results?
Asked once · last asked Oct 11 · Concept · Junior
Other ways it was asked
- “Why can't you use the WHERE clause with aggregate functions?”
A report query returns duplicate-looking employee rows after a join. How would you determine whether the duplicates are caused by the data, the relationship, or the query?
Asked once · last asked Oct 12 · Scenario · Mid-level
Write an SQL query to find all claims paid with an amount of $500.
Asked once · last asked Oct 13 · Write code · Junior
If you're asked to find the top five customers based on total sales, how would you approach the problem?
Asked once · last asked Oct 17 · Scenario · Junior
What are SQL joins, and when would you use them in testing?
Asked once · last asked Oct 22 · Concept · Junior
Write an SQL query to retrieve IDs from the `cities` table where a specified term appears in the city name.
Asked once · last asked Oct 22 · Write code · Junior
How would you use SQL for data analysis?
Asked once · last asked Jan 20 · Tooling · Junior
Other ways it was asked
- “What did you use SQL for, and how did you go about using it?”
Which SQL clauses, functions, and joins do you use to retrieve data, and what is each used for?
Asked once · last asked Feb 11 · Concept · Mid-level
How do you compare two SQL queries to determine whether their join conditions differ?
Asked once · last asked Apr 15 · Scenario · Junior
How does a right join affect the results of a SQL query?
Asked once · last asked Apr 15 · Concept · Junior
Write an SQL query to list employees ordered by salary in descending order.
Asked once · last asked May 22 · Write code · Junior
Write an SQL query to find employees whose names contain the string “ar.”
Asked once · last asked May 22 · Write code · Junior
What are the types of joins in PostgreSQL?
Asked once · last asked May 29 · Concept · Junior
What are we grouping in SQL when we use GROUP BY?
Asked once · last asked Jul 16 · Concept · Junior
Explain INNER JOIN and LEFT JOIN in PostgreSQL.
Asked once · last asked Jul 21 · Concept · Junior
What is the purpose of DISTINCT in a SELECT statement?
Asked once · last asked Jul 26 · Concept · Junior
Other ways it was asked
- “What is the use of the DISTINCT statement in a SELECT clause?”
What criteria would you use to define a valid sales record when calculating the best-selling product by total quantity sold?
Asked once · last asked Aug 3 · Scenario · Mid-level
Can you explain inner joins, left joins, and right joins?
Asked once · last asked Aug 4 · Concept · Junior
What is the difference between JOIN and UNION?
Asked once · last asked Aug 5 · Concept · Junior
What condition must be met to use UNION between two queries?
Asked once · last asked Aug 5 · Concept · Junior
What are the joins in MySQL?
Asked once · last asked Aug 12 · Concept · Junior
Why might you join an employee table with a department table when the employee table already contains salary and department ID?
Asked once · last asked Aug 15 · Concept · Junior
Can you use a SQL HAVING clause with GROUP BY, and what does it do?
Asked once · last asked Dec 6 · Concept · Junior
Can you explain the difference between GROUP BY and ORDER BY?
Asked once · last asked Aug 22 · Concept · Junior
What does AVG mean, and why would you use it?
Asked once · last asked Aug 25 · Concept · Junior
What does UNION ALL do in SQL?
Asked once · last asked Aug 26 · Concept · Junior
Can you tell me more about SQL joins?
Asked once · last asked Sep 2 · Concept · Junior
What types of joins do you know?
Asked once · last asked Sep 9 · Concept · Junior
What could cause a SQL percentage calculation to return 100%?
Asked once · last asked Sep 9 · Scenario · Mid-level
How does a WHERE condition affect the query?
Asked once · last asked Sep 9 · Concept · Junior
Why might a SQL query use MIN(floor) when grouping employee floor-access records?
Asked once · last asked Sep 10 · Concept · Junior
How do you fetch common records from two tables without a join?
Asked once · last asked Sep 11 · Concept · Junior
How do you calculate percentage in SQL?
Asked once · last asked Sep 11 · Concept · Junior
Write a SQL query that uses a WHERE clause.
Asked once · last asked Sep 14 · Write code · Junior
Can you write the SQL to retrieve the top ten products from the product table?
Asked once · last asked Sep 14 · Write code · Junior
What does a country filter in a SQL WHERE clause do to the rows returned?
Asked once · last asked Sep 18 · Concept · Junior
In an outer join, what value is returned for columns on the side with no matching row?
Asked once · last asked Sep 18 · Concept · Junior
Which join does a plain JOIN use implicitly?
Asked once · last asked Sep 21 · Concept · Junior
What rows does an INNER JOIN return when joining two tables?
Asked once · last asked Sep 22 · Concept · Junior
Write a SQL query to join the student and exam tables.
Asked once · last asked Sep 25 · Write code · Junior
How would you write a SQL query to count the rows in a table named `car`?
Asked once · last asked Sep 25 · Write code · Junior
How can you use a composite key in a WHERE clause to select records?
Asked once · last asked Oct 6 · Concept · Mid-level
How can you use GROUP BY to find duplicate records in a table?
Asked once · last asked Oct 7 · Concept · Junior
How would you write SQL to get only active users sorted by name?
Asked once · last asked Oct 8 · Write code · Junior
What result does a SQL query with GROUP BY return?
Asked once · last asked Oct 16 · Concept · Junior
How do SQL joins work?
Asked once · last asked Oct 22 · Concept · Junior
More SQL interview questions
- All SQL interview questions
- SQL Basics Interview Questions
- Database Design Interview Questions
- Advanced SQL Query Interview Questions
- SQL Views and Stored Procedures Interview Questions
- SQL Query Optimization and Indexing Interview Questions
- SQL Transactions and Concurrency Interview Questions
- Database Integration and Security Interview Questions
- Database Administration and Scaling Interview Questions
How this list is made
Every question here was asked by a real interviewer in a real job interview that a candidate ran MeetAssist in. After the call, the interviewer's questions are pulled from the transcript. Practice sessions, tests, exams and anything that was not a job interview are dropped.
Questions are rewritten so they make sense on their own: names of people, employers and clients are removed, and speech-to-text mistakes are fixed. Small talk, logistics and questions about one candidate's own résumé are left out. Rephrasings of the same question are merged, and the count is the number of different interviews it came up in.
The interviews come from candidates who use MeetAssist, so they lean towards software, data and AI roles: the shares describe these interviews, not every SQL interview. Answers to the most asked questions are written and checked by an editor; a "common mistake" is shown only when reviews of real answers in these interviews show it, with the count.
612 interviews, 357 candidates, Nov 2025 to Oct 2026. Updated every month with new interviews.
Or add the Chrome extension