I’m trying to get the max of column:
select * from
( select col1, count(*) as cnt from talbe1
group by col1
) dt
where cnt = max(cnt)
I tried to get exact value and it worked such as:
where cnt = 5
or
where cnt > 3
that was OK so what is wrong with the first query?
Edit: the numbers I put there (5, 3) are completely random, I want to get the maximum number of cnt.
Aggregate clauses have to go in the
HAVINGsection. However, this won’t work with your query as is. What you probably wanted to do was: