# S&P Global Core CS Questions with Answers

8 previously-asked core cs questions from S&P Global's hiring process, each with the correct answer and a worked explanation. Written against the company's actual test pattern.

_Source: Astra (https://useastra.in). Updated 2026-09-05._

### 1. Which SQL clause groups rows so aggregate functions can be applied per group?

A. WHERE
B. GROUP BY
C. ORDER BY
D. JOIN

**Answer:** GROUP BY

**Explanation:** GROUP BY collects rows sharing a value so aggregates like SUM run per group.

### 2. Which SQL aggregate function returns the average of a numeric column?

A. SUM
B. AVG
C. COUNT
D. MAX

**Answer:** AVG

**Explanation:** AVG computes the arithmetic mean of the values in a column.

### 3. Which SQL join returns all rows from both tables, matched where possible?

A. Inner join
B. Left join
C. Full outer join
D. Cross join

**Answer:** Full outer join

**Explanation:** A full outer join returns matched rows plus unmatched rows from both sides, filling gaps with null.

### 4. Which index type preserves order and is efficient for range queries?

A. B-tree index
B. Hash index
C. Bitmap only
D. No index

**Answer:** B-tree index

**Explanation:** A B-tree keeps keys sorted, so it supports range scans and ordering; hash indexes do not preserve order.

### 5. Which data type should you use to store monetary values precisely?

A. decimal / numeric
B. float
C. double
D. int

**Answer:** decimal / numeric

**Explanation:** decimal or numeric stores exact fixed-point values, avoiding the rounding errors of float and double.

### 6. Which SQL clause filters individual rows before any grouping happens?

A. WHERE
B. HAVING
C. GROUP BY
D. ORDER BY

**Answer:** WHERE

**Explanation:** WHERE filters rows before grouping; HAVING filters groups afterward.

### 7. Which SOLID principle states a class should have only one reason to change?

A. Single Responsibility
B. Open Closed
C. Liskov Substitution
D. Dependency Inversion

**Answer:** Single Responsibility

**Explanation:** The Single Responsibility Principle says a class should do one thing and have one reason to change.

### 8. What is the time complexity of an efficient comparison based sort?

A. O(n)
B. O(n log n)
C. O(n^2)
D. O(1)

**Answer:** O(n log n)

**Explanation:** Comparison sorts such as merge sort and heap sort run in O(n log n) in the worst case.

More S&P Global preparation, including the full recruitment process: https://useastra.in/campus/s-and-p-global
