Esta simples consulta:
select exam.id as exam_id,
(select count(*) from dataset where dataset.id = exam.id) as n_dataset
from exam
where n_dataset = 0
retorna o seguinte erro:
ERROR 1054 (42S22) at line 1: Unknown column 'n_dataset' in 'where clause'
Por quê?