Are you preparing for an upcoming TCS placement drive or interview? If yes, then one of the most important topics you must master is SQL. TCS is known to test database fundamentals, especially SQL queries, during its technical interview rounds and aptitude tests.
This blog covers the most frequently asked SQL queries in TCS, with answers, real-world examples, and explanations to help you prepare like a pro.
๐จโ๐ป Why TCS Focuses on SQL?
TCS (Tata Consultancy Services) works with data-intensive enterprise applications, and SQL is the foundation for working with databases. Whether you’re applying for roles like:
- System Engineer
- Associate Software Developer
- Database Analyst
- Support Engineer
โyou will likely encounter SQL queries in your technical screening or live coding rounds.
๐ Common SQL Queries Asked in TCS Interviews
Hereโs a list of real SQL queries asked in TCS interviews, including basic to intermediate level. Try practicing each with a sample table like Employees
, Students
, or Orders
.
๐น 1. Find the employee with the second highest salary.
SELECT MAX(Salary)
FROM Employees
WHERE Salary < (SELECT MAX(Salary) FROM Employees);
๐น 2. Retrieve names of employees who work in the ‘HR’ department.
SELECT Name
FROM Employees
WHERE Department = 'HR';
๐น 3. Display total number of employees in each department.
SELECT Department, COUNT(*) AS TotalEmployees
FROM Employees
GROUP BY Department;
๐น 4. Find employees whose names start with ‘S’.
SELECT * FROM Employees
WHERE Name LIKE 'S%';
๐น 5. Fetch the highest-paid employee in each department.
SELECT Department, MAX(Salary) AS MaxSalary
FROM Employees
GROUP BY Department;
๐น 6. List duplicate records in a table.
sqlCopyEditSELECT Name, COUNT(*)
FROM Employees
GROUP BY Name
HAVING COUNT(*) > 1;
๐น 7. Get employee details who joined after 2022.
SELECT * FROM Employees
WHERE JoiningDate > '2022-01-01';
๐น 8. Retrieve records where salary is between 40,000 and 60,000.
SELECT * FROM Employees
WHERE Salary BETWEEN 40000 AND 60000;
๐น 9. Write a query to display employee name and department, sorted by salary descending.
SELECT Name, Department, Salary
FROM Employees
ORDER BY Salary DESC;
๐น 10. Get the count of employees who haven’t received a bonus.
SELECT COUNT(*)
FROM Employees
WHERE Bonus IS NULL;
๐ง Bonus SQL Concepts TCS Might Ask
Apart from standard queries, TCS interviews sometimes test your knowledge of:
- Joins (INNER JOIN, LEFT JOIN)
- Subqueries
- Constraints
- Normalization
- Stored Procedures (basics only)
Hereโs a quick join-based question that was asked in TCS Ninja 2023:
sqlCopyEditSELECT e.Name, d.DepartmentName
FROM Employees e
INNER JOIN Departments d ON e.DepartmentID = d.ID;
๐ก Tips to Crack SQL Round in TCS
- Stick to core basics like SELECT, WHERE, GROUP BY, HAVING, JOIN.
- Practice in a live SQL playground like SQLBolt or LeetCode.
- Revise 10โ15 real-world questions from past year placement papers.
- Don’t memorize queries โ understand the logic and flow.
- Practice under time constraints to simulate actual interview pressure.
โFAQs โ SQL Queries Asked in TCS
Q1: How many SQL questions are asked in TCS interviews?
Usually, 2โ3 SQL queries appear in the technical round. Some may appear in MCQ format in the online test.
Q2: Are advanced SQL questions asked in TCS?
For roles like TCS Digital or experienced candidates, you may get JOINs, subqueries, and optimization-related questions.
Q3: Do I need to write the full SQL syntax in interviews?
Yes, especially in face-to-face or online coding rounds, where the interviewer expects you to write syntactically correct queries.
๐ Final Words
Mastering these SQL queries asked in TCS will give you an edge over other candidates. Remember, TCS wants to test your ability to manipulate and retrieve data โ not just memorize syntax. So keep practicing with logic and structure in mind.
Best of luck for your TCS interview โ you’ve got this!