您将如何实现这个查询?记录集或 Sql
我刚刚在几天前的面试测试中看到这个问题,我有下表,
Region Company Sales ratio_of_sales_in_region percentile_in_region
NA A1 1000 0.25 25
NA A2 1000 0.25 50
NA A3 1000 0.25 75
NA A4 1000 0.25 100
EU B1 2000 0.5 50
EU B2 1000 0.25 75
EU B3 1000 0.25 100
.......
我需要提取每个地区第 30 个百分位的公司和销售额 结果将是
Region 30th_percentile_company 30th_percentile_sales
NA A2 (1000*0.25 + 500 * 0.05)
EU B1 2000 (as B1 accounts for more than 30%)
查询需要检查上述条件,例如一家公司是否已占 30% 以上,并计算每个地区 30% 销售额的权重。
编辑:我试图通过添加新列来解释百分位数的含义。我很困惑,但我看到了所询问的结果表,它清楚地说明了 30% 的含义
I just saw this question in an interview test I took few days back, I have the following table
Region Company Sales ratio_of_sales_in_region percentile_in_region
NA A1 1000 0.25 25
NA A2 1000 0.25 50
NA A3 1000 0.25 75
NA A4 1000 0.25 100
EU B1 2000 0.5 50
EU B2 1000 0.25 75
EU B3 1000 0.25 100
.......
I need to extract the 30th percentile company and sales for each region
the result would be
Region 30th_percentile_company 30th_percentile_sales
NA A2 (1000*0.25 + 500 * 0.05)
EU B1 2000 (as B1 accounts for more than 30%)
The query would need to check for the above conditions like does a company already account for more than 30% and also take the weight for 30 percentile sales for each region.
EDIT : I have tried to explain what percentile means by adding a new column. I was confused but I saw the result table that was asked and it made it clear as to what they meant by 30th percentile
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)