我有一个要求,我有数据
StageID Department Number UserEmail
732 60012 user1@testing.com
733 60012 user1@testing.com
734 60012 user1@testing.com
735 60012 user2@testing.com
736 60012 user2@testing.com
737 60013 user3@testing.com
738 60013 user3@testing.com
我想得到这样的输出
StageID Department Number UserEmail DRank
732 60012 user1@testing.com 1
733 60012 user1@testing.com 1
734 60012 user1@testing.com 1
735 60012 user2@testing.com 2
736 60012 user2@testing.com 2
737 60013 user3@testing.com 1
738 60013 user3@testing.com 1
我希望在对记录进行排名时考虑DepartmentNumber和UserEmail的组合。我在分区上使用DENSE_RANK()来实现这一点,但不知何故我无法获得我想要的输出。我不确定我哪里出错了。有人可以帮我吗
这是我使用的查询
SELECT StageID, DepartmentNumber, UserEmail
,DENSE_RANK() OVER (PARTITION BY DepartmentNumber, UserEmail
ORDER BY DepartmentNumber, UserEmail ASC) AS DRANK
FROM mytable