简体   繁体   English

sql的数据挖掘问题

[英]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? 问题:您将如何确定有多少现有客户购买了其他套餐/电话?

  1. Visitors – anyone who visited the site (anyone on site) 访问者–访问该网站的任何人(网站上的任何人)
  2. Prospects – any consumer who visited the site, but did not log into an account (logging into an account would indicate they were an existing customer) 潜在客户–任何访问过该网站但未登录帐户的消费者(登录帐户将表明他们是现有客户)
  3. Customers – consumers who have logged into their site account online 客户–在线登录其网站帐户的消费者
  4. Hotphone Buyers – consumers who have purchase a wireless phone & plan on site Hotphone买家–已在现场购买无线电话和套餐的消费者

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列表示匹配的数据

Indicate file1, file2 and column to be compared 指明要比较的文件1,文件2和列

Count: 计数:

Counts rows. 计算行数。 Column to be counted must be indicated. 必须指出要计数的列。

Find: 找:

Allows one to find data that matches criteria. 允许查找符合条件的数据。 Column to be searched must be indicated. 必须指出要搜索的列。

Join : 加盟:

Joins 2 files. 加入2个文件。 Files must be sorted by join column first. 文件必须首先按连接列排序。 Resulting file is the join column in column 1, all other columns in file 1 and all other columns in file 2. Indicate file1, file2 and column to be joined. 结果文件是第1列中的join列,文件1中的所有其他列以及文件2中的所有其他列。指示file1,file2和要连接的列。

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: 分类:

Sorts data. 排序数据。 Column to be sorted must be indicated 必须指出要排序的列

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM