[英]data mining problem for sql
I only can use Compare , Count ,Find ,Join , Save and sort to do this. 我只能使用Compare,Count,Find,Join,Save和sort来做到这一点。
question: What would you do to determine how many existing customers purchased another plan / phone? 问题:您将如何确定有多少现有客户购买了其他套餐/电话?
table looks like this 桌子看起来像这样
Date / Label / UserID / Demographic Bucket/ Zip Code/ Time_Stamp 日期/标签/用户ID /受众特征存储区/邮政编码/时间戳
these are the only commands we are allowed to use !! 这些是我们唯一可以使用的命令! :(
:(
Compare: Comparison of 2 data files. 比较:2个数据文件的比较。 Column 1 indicates the data that matches
第1列表示匹配的数据
Count: 计数:
Find: 找:
Join : 加盟:
Save: Allows you to save the results from a command. 保存:允许您保存命令的结果。 Eg if you Find x on column 2, the results will be only that data that qualifies.
例如,如果您在第2列上找到x,则结果将仅是符合条件的数据。 Use –k1 to save only column 1 , –k2 to save only column 2, etc.
使用–k1仅保存第1列,–k2仅保存第2列,依此类推。
sort: 分类:
Compare, Find, Save and Sort are not SQL keywords. 比较,查找,保存和排序不是SQL关键字。
What would you do to determine how many existing customers purchased another plan / phone?
您将如何确定有多少现有客户购买了其他套餐/电话?
SELECT COUNT(*)
FROM (SELECT t.userid
FROM TABLE t
WHERE t.userid IS NOT NULL
--AND what determines a phone/plan would go here?
GROUP BY t.userid
HAVING COUNT(t.userid) > 1) x
The userid not being null qualifies as a customer, because to be logged in they should have a userid. 不为null的userid符合客户资格,因为要登录,他们应该具有一个userid。 How to determine who bought a plan?
如何确定谁购买了计划? I can't tell from the info, but having more than one instance of the userid and/or plan/phone indicator satisfies the criteria for the inner query.
我无法从信息中得知,但是拥有不止一个userid和/或计划/电话指示器的实例可以满足内部查询的条件。 The outer query just counts the [distinct] userids returned.
外部查询仅计算返回的[distinct]用户ID。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.