The examples I cited are real. (When you're in the trenches, you don't need to make them up.) The database has 1,692,438 Customers and 7,823,356 Sales Orders. All 4 questions had subsecond response. But not using a single SQL statement as you suggest. Using a combination of resources: indexes, stored procedures, common functions, and other code, applied exactly as needed. And a RDBMS.
Remember, this is a discussion of relational databases, not SQL. 2 different issues.
Remember, this is a discussion of relational databases, not SQL. 2 different issues.