I have a student table and address table. I want to find out what percentage of them come from London. I have a query that looks like
SELECT (SELECT COUNT(*) FROM student
INNER JOIN address on student.address_id = address.id
WHERE city = 'Lodon')/ COUNT(*) FROM student
When I run this query I get an error
SELECT (SELECT COUNT(*) FROM student ERROR at line 1: ORA-00937: not a single-group group function
Why is this happening and how can I fix it? When I run the subquery separately it returns a single value, but why does it return multiple values when I put in a subquery? Also, if there is a cleaner query please suggest it.