📣 黑五价提前开抢|VIP一年通行证5折,蓝莓、Offer多多同步特惠
回复: 15
跳转到指定楼层
上一主题 下一主题
收起左侧

请教一道SQL 非常感谢大家!!

全局:

2019(4-6月) 分析|数据科学类 硕士 全职@meta - Other - 技术电面  | | Other | 在职跳槽

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
请教一道SQL, 实在不知道如何把both 0 0 显示出来,我自己的SQL答案是无法显示both 0, 0 的

Problem Statement:  Member can make purchase via either mobile  or desktop platform. Using the following data table to determine the total number of member and revenue for mobile-only, desktop_only and mobile_desktop.. check 1point3acres for more.
. 1point3acresThe input spending table is
member_id    date    channel   spend.--
1001    1/1/201
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
sum(spend) as total_spend, (count distinct channel) as channel_distinct-baidu 1point3acres
From table
Group by date, member_id) b
On a.date = b.date
And a. member_id = b.member_id
)
Group by date, channel.--
谢谢各位大佬,实在不知道如何改动能把0,0 加进去!
..

.google  и

评分

参与人数 1大米 +20 收起 理由
匿名用户-XGGIC + 20

查看全部评分


上一篇:ehealth visualization take home
下一篇:c1莫名其妙挂经,求分析
推荐
davyzhang 2019-7-9 13:34:33 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
回复

使用道具 举报

推荐
madeofsugar 2019-5-20 06:38:27 | 只看该作者
全局:
我是这样写的,欢迎指正。
-baidu 1point3acres
  1. create temp table both_channel
  2. as
  3. select
  4.      date
  5.      ,'both' as channel
  6.      ,sum(tot_spend) as tot_spend
  7.      ,count(*) as tot_members. 1point3acres
  8. from
    . From 1point 3acres bbs
  9. (
  10. select
  11.      member_id
  12.      ,date
  13.      ,count(distinct channel) as channel_cnt
  14.      ,sum(spend) as tot_spend
  15. from
  16.     table1
  17. group by
  18.       member_id. ----
  19.       ,date
  20. having ..
  21.      count(distinct channel)=2
  22. )
  23. group by
  24.      date;
  25. . 1point3acres
  26. create temp table main
  27. as
  28. select. Waral dи,
  29.      date
  30.      ,channel
  31.      ,sum(spend) as tot_spend.--
  32.      ,count(distinct member_id) as tot_member
  33.      ,max(case when c.date is null then 1 else 0 end) as is_both_zero  --agg function is used for keeping table at date+channel granularity.google  и
  34. from
  35.     table1 as t
  36.     left join both_channel as c. check 1point3acres for more.
  37.          on t.date=c.date
  38. group by
  39.       date
  40.       ,channel;
  41.       .--
  42. select * from
  43. (. check 1point3acres for more.
  44. select
  45.      date
  46.      ,channel.
  47.      ,tot_spend
  48.      ,tot_member
  49. from
  50.     main. 1point3acres.com
  51. where
  52.     is_both_zero=0
  53. union all
  54. select
  55.      date
  56.      ,channel
  57.      ,tot_spend
  58.      ,tot_member
  59. from
  60.     both_channel
  61. union all.
  62. select
  63.      date
  64.      ,'both' as channel
  65.      ,0 as tot_spend
  66.      ,0 as tot_member
  67. from
  68.     main
  69. where
  70.     is_both_zero=1  
  71. )
  72. order by. 1point3acres.com
  73.      date
  74.      ,channel
  75.      ,tot_spend
  76.      ,tot_member;   
  77. . 1point 3 acres
复制代码

评分

参与人数 2大米 +11 收起 理由
rongy2018 + 1 给你点个赞!
匿名用户-XGGIC + 10

查看全部评分

回复

使用道具 举报

推荐
albeehere 2019-5-21 03:13:19 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies

评分

参与人数 1大米 +10 收起 理由
匿名用户-XGGIC + 10

查看全部评分

回复

使用道具 举报

全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies

评分

参与人数 1大米 +10 收起 理由
匿名用户-XGGIC + 10

查看全部评分

回复

使用道具 举报

🔗
magicsets 2019-5-20 14:27:03 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies

评分

参与人数 1大米 +10 收起 理由
匿名用户-XGGIC + 10

查看全部评分

回复

使用道具 举报

🔗
wrencer 2019-5-21 02:47:43 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies

评分

参与人数 1大米 +10 收起 理由
匿名用户-XGGIC + 10

查看全部评分

回复

使用道具 举报

🔗
bellacongcong 2019-5-21 05:39:10 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies

评分

参与人数 1大米 +10 收起 理由
匿名用户-XGGIC + 10

查看全部评分

回复

使用道具 举报

🔗
xee7 2019-5-21 07:08:22 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies

评分

参与人数 1大米 +10 收起 理由
匿名用户-XGGIC + 10

查看全部评分

回复

使用道具 举报

🔗
wrencer 2019-5-21 09:08:45 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies

评分

参与人数 1大米 +10 收起 理由
匿名用户-XGGIC + 10

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表