Practice · History · Hard
In one row, return the total number of obelisks as total, how many stand outside Egypt as abroad, and the percentage abroad as pct_abroad rounded to 1 decimal.
Runs in your browser. No signup needed.
obelisks(current_country). Use COUNT(*) with a conditional SUM(CASE WHEN ... THEN 1 ELSE 0 END), and multiply by 100.0 to force real division.
SELECT COUNT(*) AS total,
SUM(CASE WHEN ... THEN 1 ELSE 0 END) AS abroad,
ROUND(...) AS pct_abroad
FROM obelisks;
The reference solution is checked automatically when you run your query on the practice page — results are compared row by row.
Integer division is the classic trap: 18/33 is 0 in SQL until you multiply by 100.0 and make it a real number.