I have an Enroll TableEnrollIDAgentIDEnrollmentDateI want to list how many Agents did how many Enrollments using the Rankfunction in SQL Server 05/08. How to do?Output needs to be :Position AgentId CountEnroll1 62 292 55 223 34 19
A helpful user visakh suggested me this query:select agentid, countEnroll,,rank() over( partition by agentid order by countEnroll desc) as rnk from ( select agentid,count(EnrollID) as countEnroll from urtable group by agentid) t
But when I run query, it gives me Rank = 1 for all rows. Please say what tocorrecT?