Here is the problem.
select count(studentID) AS count from educators where count > 1 group by studentid
Will not work as SQL Server does not yet know about the count column.
So I have to do this
select *
from (select count(StudentID) as count
from educators
group by studentid
) s
where s.count > 1
Is there a more elegant solution? It seems like there should be a much nicer way to do this.
You could use the
HAVINGclause, maybe something like this:The query will display all StudentIDs that appear more than once.