Hello guys I am having a problem which is eating me for hours. What I am trying to do is count how many rows have same value from table t2 and show only max values not all of them. But I get error. How I can solve this problem? I can't find specific answer.
Msg 130, Level 15, State 1, Line 5 Cannot perform an aggregate function on an expression containing an aggregate or a subquery.
.
SELECT t1.operatoriausPavadinimas,count(t2.operatoriausID) as ct
FROM Operatorius t1,Planas t2
WHERE t1.operatoriausID=t2.operatoriausID
Group by t1.operatoriausPavadinimas
Having COUNT(t2.operatoriausID)>=MAX(COUNT(t2.operatoriausID))