What is SQL, and what kinds of problems does it solve that a hand-written loop would not?
SQL (Structured Query Language) is the standard language for asking a relational database questions and for changing what it stores. You describe what you want — the customers in London, the orders over 500 dollars — and the database engine figures out how to produce those rows, using indexes, statistics and a query planner that a hand-written loop would never have.
That declarative split is the whole point. A procedural loop over a customer list must decide for itself which index to use and when to stop scanning; a query optimizer with accurate table statistics makes that decision from the data. SQL also gives you a transaction boundary, so a transfer can move money between two rows or change nothing at all.
CREATE TABLE customers (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
city TEXT NOT NULL
);
INSERT INTO customers (id, name, city) VALUES
(1, 'Ada Lovelace', 'London'),
(2, 'Grace Hopper', 'New York'),
(3, 'Alan Turing', 'London');
SELECT city, COUNT(*) AS customer_count
FROM customers
GROUP BY city
ORDER BY customer_count DESC, city;The result is two rows: London with 2 customers, New York with 1. The same statement shape answers payroll questions, inventory questions and reporting questions, which is why the language survives every change in storage engine. The trade-off is that SQL only reaches what the database exposes: you cannot ask it to hold a row lock while you make a third-party HTTP call, and a badly written query can move far more rows than you intended. Interviewers want to see that you understand the split between declaring intent and letting the engine plan the work.