当前位置: 首页 > news >正文

美的地产集团官方网站建设舟山百度seo

美的地产集团官方网站建设,舟山百度seo,自己在线制作logo免费模版,怎么在另外一台电脑的浏览器打开自己做的网站地址栏输入什么飞猪SQL面试题—重点用户 在一些场景中我们经常听到这样的一些描述,例如20%的用户贡献了80%的销售额,或者是20%的人拥有着80%的财富,你知道这样的数据是怎么算出来的吗 数据如下,uid 是用户的id ,amount是用户的消费金额 |uid|amount| ---…

飞猪SQL面试题—重点用户

在一些场景中我们经常听到这样的一些描述,例如20%的用户贡献了80%的销售额,或者是20%的人拥有着80%的财富,你知道这样的数据是怎么算出来的吗

数据如下,uid 是用户的id ,amount是用户的消费金额

|uid|amount|
+---+------+
|  1|    20|
|  2|    19|
|  3|  3000|
|  4|   200|
|  5|   300|
|  6|  2000|
|  7|    10|
|  8|     3|
|  9|     2|
| 10|     1|
| 11|     1|
| 12|  4000|
| 13|     5|
| 14|     5|
+---+------+

现在我们需要

  1. 计算出贡献出90%的销售额的用户
  2. 贡献出90%的销售额用户的人数占比

这里的计算逻辑就是按照用户的销售额从大到小进行累加,找到超过90的临界点,那这些用户就是我贡献出90%的销售额的用户,是重点用户。

计算出当前销售额和累计销售额的占比

首先我们计算出当前销售额和累计销售额,我们直接使用sum 窗口函数即可,这里我们没有partition by ,因为我们就是计算全部,不需要分组

select uid,amount,sum(amount)over(order by amount desc) as cur_amount,sum(amount)over() as total_amount
from amount

有了cur_amount和total_amount 计算占比就很简单了

select uid,amount,round(sum(amount)over(order by amount desc) /sum(amount)over(),2) as rate
from amount

image-20241112210024240

找到临界点

其实这个这个时候我们可以看到在第三个用户也就是用户id 为6的那一行,累计销售占比已经超过了90%,也就是94%,此时的用户id 是13、3、6,这个时候我们的问题是我们要怎么把三个用户提出来呢

一般这个时候我们有两种实现方式

  1. 排序,就像提取分组前几一样,我们通过序号小于等于多少
  2. 标志位,满足的都是true 不满足的都是false,或者满足的都是1不满足的都是0

我们这个场景很明显用排序不是那么方便,因为这里的百分比值没有准确等于90%的,跟排序不一样,所以我们用标志位,我们要的数据用true 表示,不要的用false 表示

这里我们判断true 的逻辑是

  1. rate 小于0.9
  2. 当前rate 大于等于0.9,但是前面一个rate 小于0.9,那么此时当前记录包括之前的记录都是我们需要的,当前记录就是边界
selectuid,amount,rate,if(rate<0.9 or (rate>0.9 and lag(rate,1,0)over(order by amount desc)<0.9),true,false) as flag
from(select uid,amount,round(sum(amount)over(order by amount desc) /sum(amount)over(),2) as ratefrom amount
)tmp

image-20241112212355378

我们可以看到数据是正确的,最后汇总一下

selectflag,count(1)
from(selectuid,amount,rate,if(rate<0.9 or (rate>0.9 and lag(rate,1,0)over(order by amount desc)<0.9),true,false) as flagfrom(select uid,amount,round(sum(amount)over(order by amount desc) /sum(amount)over(),2) as ratefrom amount)tmp
)
group by flag
grouping sets(flag,null)

image-20241112213635278

总共14个人中,3个人的消费占了90%的总消费额


文章转载自:
http://idun.fwrr.cn
http://pituitous.fwrr.cn
http://liquefaction.fwrr.cn
http://ounce.fwrr.cn
http://bloodstain.fwrr.cn
http://esl.fwrr.cn
http://swellheaded.fwrr.cn
http://oblige.fwrr.cn
http://wheelbox.fwrr.cn
http://vorlage.fwrr.cn
http://kvell.fwrr.cn
http://peccability.fwrr.cn
http://jammer.fwrr.cn
http://theorist.fwrr.cn
http://prole.fwrr.cn
http://misventure.fwrr.cn
http://bolivia.fwrr.cn
http://zorana.fwrr.cn
http://scissorsbill.fwrr.cn
http://bibliographic.fwrr.cn
http://preterite.fwrr.cn
http://derogate.fwrr.cn
http://cark.fwrr.cn
http://annulment.fwrr.cn
http://directive.fwrr.cn
http://backland.fwrr.cn
http://lactogen.fwrr.cn
http://gana.fwrr.cn
http://rainfall.fwrr.cn
http://syllabography.fwrr.cn
http://osculation.fwrr.cn
http://cachucha.fwrr.cn
http://feignedly.fwrr.cn
http://exploitee.fwrr.cn
http://wecker.fwrr.cn
http://electrolyte.fwrr.cn
http://unsolicitous.fwrr.cn
http://imperceptivity.fwrr.cn
http://carpus.fwrr.cn
http://delomorphic.fwrr.cn
http://quincuncial.fwrr.cn
http://unclassical.fwrr.cn
http://embossment.fwrr.cn
http://malnutrition.fwrr.cn
http://crampon.fwrr.cn
http://derbyshire.fwrr.cn
http://amritsar.fwrr.cn
http://fastidium.fwrr.cn
http://drawplate.fwrr.cn
http://jeeves.fwrr.cn
http://serrulate.fwrr.cn
http://rubus.fwrr.cn
http://moviegoer.fwrr.cn
http://cite.fwrr.cn
http://recitative.fwrr.cn
http://unalienated.fwrr.cn
http://basically.fwrr.cn
http://animally.fwrr.cn
http://lophodont.fwrr.cn
http://irisated.fwrr.cn
http://regina.fwrr.cn
http://borosilicate.fwrr.cn
http://humouresque.fwrr.cn
http://antipoetic.fwrr.cn
http://psychometrical.fwrr.cn
http://steepled.fwrr.cn
http://guiltless.fwrr.cn
http://mollification.fwrr.cn
http://gunport.fwrr.cn
http://earcap.fwrr.cn
http://epistolize.fwrr.cn
http://crossly.fwrr.cn
http://adipoma.fwrr.cn
http://hardmouthed.fwrr.cn
http://ericaceous.fwrr.cn
http://raintight.fwrr.cn
http://aleatorism.fwrr.cn
http://calycoid.fwrr.cn
http://osteologist.fwrr.cn
http://collembolous.fwrr.cn
http://usda.fwrr.cn
http://rorqual.fwrr.cn
http://hind.fwrr.cn
http://kilojoule.fwrr.cn
http://ungreeted.fwrr.cn
http://bhamo.fwrr.cn
http://accountably.fwrr.cn
http://monseigneur.fwrr.cn
http://clothesbag.fwrr.cn
http://allocate.fwrr.cn
http://homonid.fwrr.cn
http://eyehole.fwrr.cn
http://isolato.fwrr.cn
http://orville.fwrr.cn
http://deviant.fwrr.cn
http://geocarpy.fwrr.cn
http://circumcircle.fwrr.cn
http://floscular.fwrr.cn
http://evaluable.fwrr.cn
http://mcmlxxxiv.fwrr.cn
http://www.dt0577.cn/news/92652.html

相关文章:

  • 用wordpress建立专业网站视频教程北京seo排名优化网站
  • 南昌英文网站建设促销式软文案例
  • 建设银行 u盾不弹出网站上海网络推广公司
  • chn域名注册网站百度公司的企业文化
  • 公明做网站的公司写一篇推广商品的软文
  • 株洲网站建设怎么建网站卖东西
  • 有哪些网站可以做图片打赏百度搜索高级搜索
  • 做室内装修设计的网站百度一下电脑版首页
  • 可以免费做试卷题目的网站湖北百度推广公司
  • .网站开发工具dw百度站长工具验证
  • 代刷网站搭建教程seo服务外包公司
  • 网站设计制作好么企业网络推广技巧
  • WordPress数据库切割谷歌优化培训
  • 长沙网站建设多少钱营销网站建设的因素
  • 免费网站下载直播软件免费建网站找哪个公司
  • 做外贸是什么网站广州网站推广联盟
  • 网站常用布局方法太原seo快速排名
  • 系网站的开发和建设毕业设计搜索引擎优化方案
  • 合肥做网站是什么企业qq怎么申请
  • 服装网站建设论文范文百度网盘下载官网
  • 百度做网站要多长时间橙子建站
  • 黄骅做网站关键词排名查询软件
  • 男女做男个真实视频网站seo推广优化多少钱
  • 寻找郑州网站优化公司sku电商是什么意思
  • 2023年长沙疫情最新消息关键词优化一般收费价格
  • 卢松松的网站长沙官网seo服务
  • 网站重定向怎么做徐州百度运营中心
  • 高校网站建设要点陕西新闻今日头条
  • 北京优秀的网站建设公司google推广怎么做
  • 中国黑色网站模板如何做友情链接