I have spent 2 days trying this using OLAP functions like ROw_number but does not work out in all cases. and I am not allowed to create a procedure.
This is my lookup table. Team Hierarchy Cnt_Tasks SEQ_NUM Team-B 1 22774 1 Team-R 1 11387 2 Team-G 1 1000 3 Team-R 2 1637 4 Team-Y 2 4092 5 Team-O 3 59071 6 Team-J 5 7114 7
And this one is my actual table where i need to populate the teams as per the tasks. Count_tasks column in the look up table is the number of tasks for each Hierarchy which has to be assigned ot a particular team. Eg. There are 22774 tasks with hierarchy 1 which should get assigned to Team B and 7114 tasks with hierarchy 5 should get assigned to TeamJ.