select from ... where ...;
and select from ... join ... where;
Those are the types 99% of programmers who use SQL for simple CRUD apps know. But they come up short for asking more useful business questions.Eyeballing the list, it tests subqueries, GROUP BY, HAVING, OUTER JOIN, IN/NOT IN and SUM. Fairly useful primitives for general query writing.
I'd try to add a question that relies on UNION, INTERSECT or EXCEPT.
As shown by codegeek, the 6 questions here can be answered without needing sub-query. Maybe we can add something like "List employees who are not working alone in their department"
>List all departments along with the number of people there (tricky - people often do an "inner join" leaving out empty departments)
inner join seems the non obvious way to do it really IMO.
select
departments.name as "department name",
(select sum(salary) from employees where employees.departmentid = departments.departmentid) as "department total salary"
from departmentsAn inner join will hide that row because there's no equality between a set (departments) and an empty set (employees in that dept, of which there are none). A correctly structured outer join will.