I want to calculate ranking for every Emp_Id based on who have generated more no of TGenerate(For ex in tbl_Generate 101 has generated total 2 and 102 generated total 3 Tgenerate) and Emp_Id who have highest count of status as delieverd(For ex 101 has total 2 delivered count).
So how do I write sql query to get rank on the basis of those two attributes(TGenerate and Status). And How do I get total count whose status is not Delivered. P.S.:- I am using SQL Server 2012.