使用Access SQL执行分组排名
发布时间:2021-03-12 06:14:07 所属栏目:MsSql教程 来源:网络整理
导读:如何按部门分组的#客户(包括关系)对销售人员进行排名? 例如,给定此表,我想在右侧创建Rank列.我应该如何在Access中执行此操作? SalesPerson Dept #Customers RankBill DeptA 20 1Ted DeptA 30 2Jane DeptA 40 3Bill DeptB 50 1Mary DeptB 60 2 我已经知道如
如何按部门分组的#客户(包括关系)对销售人员进行排名? 例如,给定此表,我想在右侧创建Rank列.我应该如何在Access中执行此操作? SalesPerson Dept #Customers Rank Bill DeptA 20 1 Ted DeptA 30 2 Jane DeptA 40 3 Bill DeptB 50 1 Mary DeptB 60 2 我已经知道如何使用这个SQL代码进行简单的排名.但我不知道如何重做这个来接受分组. Select Count(*) from [Tbl] Where [#Customers] < [Tblx]![#Customers] )+1 此外,使用SQL Server的Rank()函数有很多答案,但我需要在Access中执行此操作.建议好吗? 解决方法SELECT *,(select count(*) from tbl as tbl2 where tbl.customers > tbl2.customers and tbl.dept = tbl2.dept) + 1 as rank from tbl 只需将dept字段添加到子查询中…… (编辑:拼字网 - 核心网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |