I am trying to do the following in my query however i only have the first part and im very new at SQL so i honestly have no idea how to get it right.
The objective is:
- Find the user with the lowest case count (which i have done) as below:
Select Top 1 assigned_to_name, count(*) as Cases from CSCASES Group by assigned_to_name order by 2
This returns my results as follows:
Sue 1
- Second part of my query is to assign the next case that is created to the user with the lowest count which in this case is Sue as above.
Is this possible with a function or is it easier to do it using a Trigger or SP?
Any help would be greatly appreciated