Top SQL Interview Questions: TCS, Infosys, Wipro

TCS, Infosys, Wipro, and similar IT services companies ask a fairly predictable set of SQL questions in their technical rounds — they favor fundamentals over trick questions. This guide covers the most frequently asked questions with expected answers and worked query examples, based on patterns commonly reported by candidates in campus and lateral hiring interviews.

Q1: What is the difference between DELETE, TRUNCATE, and DROP?

This is one of the most commonly asked SQL theory questions. DELETE removes rows one at a time, can use a WHERE clause, is logged, and can be rolled back inside a transaction. TRUNCATE removes all rows at once, resets identity columns, and cannot use WHERE. DROP removes the entire table structure along with its data.

DELETE FROM employees WHERE department = 'HR';   -- removes matching rows
TRUNCATE TABLE employees;                          -- removes all rows, keeps structure
DROP TABLE employees;                               -- removes table and data entirely

Q2: Write a query to find the second highest salary

A classic query-writing question. The most portable solution uses a subquery with LIMIT and OFFSET:

SELECT DISTINCT salary
FROM employees
ORDER BY salary DESC
LIMIT 1 OFFSET 1;

An alternative that also works in older MySQL versions without OFFSET:

SELECT MAX(salary) AS second_highest
FROM employees
WHERE salary < (SELECT MAX(salary) FROM employees);

Q3: Explain the different types of JOIN

Interviewers expect you to explain INNER JOIN (only matching rows in both tables), LEFT JOIN (all rows from the left table plus matches from the right), RIGHT JOIN (all rows from the right table plus matches from the left), and FULL OUTER JOIN (all rows from both tables, matched where possible).

SELECT e.name, d.department_name
FROM employees e
LEFT JOIN departments d ON e.department_id = d.id;

Q4: What is normalization? Name the first three normal forms

Normalization organizes tables to reduce redundancy and prevent update anomalies. First Normal Form (1NF) requires atomic column values with no repeating groups. Second Normal Form (2NF) requires 1NF plus every non-key column depending on the entire primary key. Third Normal Form (3NF) requires 2NF plus removing transitive dependencies, where non-key columns should not depend on other non-key columns.

Q5: Common query-writing round questions

  • Write a query to count employees in each department using GROUP BY.
  • Find departments with more than 5 employees using GROUP BY and HAVING.
  • Write a query using a subquery to find employees earning above the company average salary.
  • Write a query to list employee names along with their manager's name using a self-join.

Example of the self-join pattern, which frequently appears in these interviews:

SELECT e.name AS employee, m.name AS manager
FROM employees e
LEFT JOIN employees m ON e.manager_id = m.id;

Frequently Asked Questions

What SQL topics do TCS, Infosys, and Wipro focus on in interviews?

These companies typically test SELECT fundamentals, JOIN types, GROUP BY with HAVING, subqueries, the difference between DELETE, TRUNCATE, and DROP, and basic normalization concepts.

Is SQL asked in the technical round or only in the coding round?

SQL is usually asked in both — as theory questions in the technical interview round, and sometimes as a hands-on query-writing exercise in the coding or written test round.

How can I practice SQL interview questions before an IT services interview?

Practice writing queries by hand on sample tables covering joins, aggregation, and subqueries, and use an AI SQL generator to check your query against the plain English version of the question.

Try the Free AI SQL Query Builder

Practice interview questions faster — describe a query in plain English and compare it against the generated SQL.

Related articles