SQL Queries Asked in Accenture & Capgemini Interviews

Accenture and Capgemini run high-volume technical interviews for both freshers and experienced hires, and SQL is one of the most consistently tested topics. This guide collects the SQL questions candidates most frequently report from these interviews, along with clear explanations and working query examples.

Q1: Difference between WHERE and HAVING

This is asked in nearly every service company interview. WHERE filters rows before any grouping happens and cannot use aggregate functions. HAVING filters groups after GROUP BY, and is typically used with aggregates like COUNT, SUM, or AVG.

SELECT department, COUNT(*) AS emp_count
FROM employees
WHERE status = 'active'
GROUP BY department
HAVING COUNT(*) > 10;

Q2: Write a query to find the Nth highest salary

A very common follow-up to the "second highest salary" question. Using DENSE_RANK() handles ties correctly:

WITH ranked_salaries AS (
  SELECT
    name,
    salary,
    DENSE_RANK() OVER (ORDER BY salary DESC) AS salary_rank
  FROM employees
)
SELECT name, salary
FROM ranked_salaries
WHERE salary_rank = 3;  -- change 3 to N

Q3: Primary key vs foreign key vs unique key

A primary key uniquely identifies each row in a table and cannot be NULL. A foreign key references the primary key of another table to enforce referential integrity. A unique key also enforces uniqueness like a primary key, but a table can have multiple unique keys and they can allow one NULL value (in most databases).

Q4: Write a query to find employees who joined in the last 6 months

Date filtering questions are common in both Accenture and Capgemini rounds:

-- MySQL
SELECT name, join_date
FROM employees
WHERE join_date >= DATE_SUB(CURDATE(), INTERVAL 6 MONTH);

-- PostgreSQL
SELECT name, join_date
FROM employees
WHERE join_date >= CURRENT_DATE - INTERVAL '6 months';

Q5: Common conceptual questions to prepare

  • What are ACID properties, and why do they matter for transactions?
  • What is a correlated subquery, and how is it different from a regular subquery?
  • Explain indexing and how it improves query performance.
  • What is the difference between UNION and UNION ALL?
  • What is a self-join, and give an example use case (such as an employee-manager relationship).

Frequently Asked Questions

What kind of SQL questions does Accenture ask in interviews?

Accenture typically asks about JOIN types, subqueries, aggregate functions, primary and foreign keys, and simple query-writing tasks like finding duplicate or top N records.

Does Capgemini ask SQL in the technical interview or written test?

Both. Capgemini often includes SQL multiple-choice questions in the written or online assessment, and follows up with query-writing or conceptual SQL questions in the technical interview round.

What is the difference between WHERE and HAVING, and is it commonly asked?

Yes, this is a very common question. WHERE filters individual rows before grouping, while HAVING filters groups after GROUP BY has been applied, typically used with aggregate functions like COUNT or SUM.

Try the Free AI SQL Query Builder

Practice these interview patterns faster — describe a question in plain English and check the generated SQL.

Related articles