sql队列分析

时间:2018-12-07 19:42:52

标签: sql

作为输入,您有2个表: -一个带有user_id,signup_timestamp的 -第二个用户名为user_id,order_timestamp

我的理解:

1 个答案:

答案 0 :(得分:0)

嗯,实际上很难解决这个问题,因为您不能使用简单的表格有效地显示答案。但是我很确定这将符合您的意愿。该代码可能有一些错误,因为我在打电话。

SELECT * FROM 
(SELECT DATEPART(week, t1.signup_timestamp) AS week, count(signup) AS purchases
FROM table1) 
t1 
FULL OUTER JOIN 
(SELECT 
DATEPART(week, t1.order_timestamp) AS week, count(signup) AS orders 
FROM table2)
t2 
on t1.week = t2.week