两道编程,一道SQL,一道距离最优
(交卷前复制了SQL的整道题目)
------------------------------------
搜索未下单用户查询
时间限制: 5000MS
内存限制: 589824KB
题目描述:
互联网时代,电商平台竞争激烈,让利促销是电商平台常有的销售手段,为多次搜索某种商品但未实际成交的"纠结"用户发放优惠券是一种常规的营销模式。 设定过去一年内对某件商品搜索次数超过3次及以上,但没有购买的用户(假定所有搜索用户都已注册并登陆)为某电商平台的"特邀用户"; 请提取这部分用户ID及浏览商品ID和名称,用以营销系统为这些用户发优惠券。
输入描述
商品信息表T_Product:(其中PID为商品ID,ProductName为商品名称)
PID INT COMMENT (商品ID)
ProductName varchar(50) COMMENT (商品名称)
搜索信息表T_Search:(其中SID为搜索ID,PID为商品ID,UID为用户UID,SearchTime为搜索日期)
SID INT COMMENT (搜索ID)
PID INT COMMENT (商品ID)
UID varchar(50) COMMENT (用户UID)
SearchTime varchar(50) COMMENT (搜索日期)
订单信息表T_Order:(其中OID为订单号,PI为商品ID,UID为用户UID,OrderTime为下单日期)
OID INT COMMENT (订单号)
PID INT COMMENT (商品ID)
UID varchar(50) COMMENT (用户UID)
OrderTime varchar(50) COMMENT (下单日期)
输出描述
输出结果包含:用户uid,商品PID,商品名称ProductName
uid pid ProductName
样例输入
create table T_Product(PID INT,ProductName varchar(50));
insert into T_Product(PID,ProductName) values(1,'HUAWEI P40');
insert into T_Product(PID,ProductName) values(2,'IPHONE11 PRO');
insert into T_Product(PID,ProductName) values(3,'XIAOMI12');
create table T_Search(SID INT,PID INT,UID varchar(50),SearchTime varchar(50));
insert into T_Search(SID,PID,UID,SearchTime) values(1,1,'IK001','2020-01-01');
insert into T_Search(SID,PID,UID,SearchTime) values(2,1,'IK002','2020-01-02');
insert into T_Search(SID,PID,UID,SearchTime) values(3,2,'IK002','2020-02-02');
insert into T_Search(SID,PID,UID,SearchTime) values(4,2,'IK002','2020-02-03');
insert into T_Search(SID,PID,UID,SearchTime) values(5,2,'IK002','2020-02-06');
insert into T_Search(SID,PID,UID,SearchTime) values(6,3,'IK003','2020-01-06');
insert into T_Search(SID,PID,UID,SearchTime) values(7,3,'IK003','2020-01-12');
insert into T_Search(SID,PID,UID,SearchTime) values(8,3,'IK003','2020-02-01');
insert into T_Search(SID,PID,UID,SearchTime) values(9,1,'IK004','2020-01-06');
insert into T_Search(SID,PID,UID,SearchTime) values(10,1,'IK004','2020-01-12');
insert into T_Search(SID,PID,UID,SearchTime) values(11,1,'IK004','2020-02-01');
insert into T_Search(SID,PID,UID,SearchTime) values(12,1,'IK004','2020-02-02');
create table T_Order(OID INT,PID INT,UID varchar(50),OrderTime varchar(50));
insert into T_Order(OID,PID,UID,OrderTime) values(1,1,'IK001','2020-01-01 10:03:10');
insert into T_Order(OID,PID,UID,OrderTime) values(2,1,'IK004','2020-02-02 20:53:00');
样例输出
uid pid ProductName
IK002 2 IPHONE11 PRO
IK003 3 XIAOMI12
时间限制: 5000MS
内存限制: 589824KB
题目描述:
互联网时代,电商平台竞争激烈,让利促销是电商平台常有的销售手段,为多次搜索某种商品但未实际成交的"纠结"用户发放优惠券是一种常规的营销模式。 设定过去一年内对某件商品搜索次数超过3次及以上,但没有购买的用户(假定所有搜索用户都已注册并登陆)为某电商平台的"特邀用户"; 请提取这部分用户ID及浏览商品ID和名称,用以营销系统为这些用户发优惠券。
输入描述
商品信息表T_Product:(其中PID为商品ID,ProductName为商品名称)
PID INT COMMENT (商品ID)
ProductName varchar(50) COMMENT (商品名称)
搜索信息表T_Search:(其中SID为搜索ID,PID为商品ID,UID为用户UID,SearchTime为搜索日期)
SID INT COMMENT (搜索ID)
PID INT COMMENT (商品ID)
UID varchar(50) COMMENT (用户UID)
SearchTime varchar(50) COMMENT (搜索日期)
订单信息表T_Order:(其中OID为订单号,PI为商品ID,UID为用户UID,OrderTime为下单日期)
OID INT COMMENT (订单号)
PID INT COMMENT (商品ID)
UID varchar(50) COMMENT (用户UID)
OrderTime varchar(50) COMMENT (下单日期)
输出描述
输出结果包含:用户uid,商品PID,商品名称ProductName
uid pid ProductName
样例输入
create table T_Product(PID INT,ProductName varchar(50));
insert into T_Product(PID,ProductName) values(1,'HUAWEI P40');
insert into T_Product(PID,ProductName) values(2,'IPHONE11 PRO');
insert into T_Product(PID,ProductName) values(3,'XIAOMI12');
create table T_Search(SID INT,PID INT,UID varchar(50),SearchTime varchar(50));
insert into T_Search(SID,PID,UID,SearchTime) values(1,1,'IK001','2020-01-01');
insert into T_Search(SID,PID,UID,SearchTime) values(2,1,'IK002','2020-01-02');
insert into T_Search(SID,PID,UID,SearchTime) values(3,2,'IK002','2020-02-02');
insert into T_Search(SID,PID,UID,SearchTime) values(4,2,'IK002','2020-02-03');
insert into T_Search(SID,PID,UID,SearchTime) values(5,2,'IK002','2020-02-06');
insert into T_Search(SID,PID,UID,SearchTime) values(6,3,'IK003','2020-01-06');
insert into T_Search(SID,PID,UID,SearchTime) values(7,3,'IK003','2020-01-12');
insert into T_Search(SID,PID,UID,SearchTime) values(8,3,'IK003','2020-02-01');
insert into T_Search(SID,PID,UID,SearchTime) values(9,1,'IK004','2020-01-06');
insert into T_Search(SID,PID,UID,SearchTime) values(10,1,'IK004','2020-01-12');
insert into T_Search(SID,PID,UID,SearchTime) values(11,1,'IK004','2020-02-01');
insert into T_Search(SID,PID,UID,SearchTime) values(12,1,'IK004','2020-02-02');
create table T_Order(OID INT,PID INT,UID varchar(50),OrderTime varchar(50));
insert into T_Order(OID,PID,UID,OrderTime) values(1,1,'IK001','2020-01-01 10:03:10');
insert into T_Order(OID,PID,UID,OrderTime) values(2,1,'IK004','2020-02-02 20:53:00');
样例输出
uid pid ProductName
IK002 2 IPHONE11 PRO
IK003 3 XIAOMI12
全部评论
(1) 回帖