Skip to content
Quantoros

Return the name and creditscore of customers in Toronto with a credit score above 700, highest score first. Table…

SQLLevel: FoundationBasics and filtering

Return the name and credit_score of customers in Toronto with a credit score above 700, highest score first.

Table definitions (from the source exercise):

CREATE TABLE customers(customer_id INTEGER PRIMARY KEY, name TEXT, city TEXT, signup_date TEXT, credit_score INTEGER);
Hints
  • Define one output row and the source-table keys.
  • Check duplicates, NULLs and the order of filtering and aggregation.

Answer

Approach: WHERE with two conditions joined by AND, then ORDER BY ... DESC.

SELECT name, credit_score
FROM customers
WHERE city = 'Toronto' AND credit_score > 700
ORDER BY credit_score DESC;

The source uses SQLite with a MySQL compatibility layer. Date and string functions are dialect dependent; the query is preserved as published.

Source and licence: SQL Practice Lab — Ebrahim Sharifi · MIT

Related questions