sql获取分组排序后数据的脚本
时间:2024-01-20 09:07:58
先上一段代码,如下所示:
select distinct
b.OrgID,b.CompanyID,b.AreaID,b.CustChannelID,b.CustID,b.SaleTotalQty,
GETDATE() from KDS400TelSurveyCustAll_Temp as tmp1 cross apply
(
select top 10 percent * from KDS400TelSurveyCustAll_Temp tmp2
where tmp1.OrgID=tmp2.OrgID and tmp1.CompanyID=tmp2.CompanyID
and tmp1.AreaID=tmp2.AreaID and tmp1.CustChannelID=tmp2.CustChannelID
and tmp2.CustChannelID in (1027,1028)
order by tmp2.OrgID,tmp2.CompanyID,tmp2.AreaID,tmp2.AreaType,tmp2.CustChannelID
) as b
这段代码的意思是获取取每个经销商在每个县级城市中两类客户
取各类客户的前3个月累计销量排名在前10%的客户进行调查。
标签:分组排序
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
我喜欢你 抖音表白程序python版
2023-06-11 12:54:17
pandas数据筛选和csv操作的实现方法
2022-04-23 15:36:21
python导入同级模块的实现
2021-03-09 10:08:51
Python中列表的一些基本操作知识汇总
2022-04-08 07:12:28
![](https://img.aspxhome.com/file/2023/1/97421_0s.jpg)
javascript 网站常用的iframe分割
2023-08-19 09:27:58
Request.ServerVariables各参数说明集合
2008-11-25 18:49:00
高效的删除HTML标签的函数
2009-02-26 13:02:00
python 输出列表元素实例(以空格/逗号为分隔符)
2023-10-03 16:40:52
tensorflow实现KNN识别MNIST
2021-08-10 06:41:50
Go 语言单例模式示例详解
2024-02-09 23:43:28
基python实现多线程网页爬虫
2023-10-30 00:58:48
golang图片处理库image基本操作
2024-04-26 17:32:04
一百多行python代码实现抢票助手
2022-05-20 00:55:52
vue3 $attrs和inheritAttrs的用法说明
2024-04-26 17:39:08
![](https://img.aspxhome.com/file/2023/3/133163_0s.png)
python中dot函数运算过程总结
2021-03-01 16:52:23
![](https://img.aspxhome.com/file/2023/1/130561_0s.png)
python实现简单反弹球游戏
2021-05-06 23:25:45
![](https://img.aspxhome.com/file/2023/1/117311_0s.jpg)
原生Js与jquery的多组处理, 仅展开一个区块的折叠效果
2024-04-17 10:06:48
![](https://img.aspxhome.com/file/2023/2/136382_0s.png)
SQL语句练习实例之一——找出最近的两次晋升日期与工资额
2024-01-19 06:19:50
Python 读取千万级数据自动写入 MySQL 数据库
2023-11-08 09:25:47
![](https://img.aspxhome.com/file/2023/0/63600_0s.jpg)
深入理解Python虚拟机中描述器的实现原理
2021-08-05 21:20:48