题.
编写解决方案,统计截至 2019-07-27
(包含2019-07-27),近 30
天的每日活跃用户数(当天只要有一条活动记录,即为活跃用户)。
select
activity_date as day,
count(distinct user_id) as active_users
from
Activity
group by day
having "2019-07-27">=activity_date and activity_date>date_add("2019-07-27",interval -30 day)
这题主要复习一下日期操作,此处日期前推时,依然使用data_add函数,将interval后数字改为负数即可。
题.
编写解决方案,报告2019年春季
才售出的产品。即仅在2019-01-01
至2019-03-31
(含)之间出售的商品。
以 任意顺序 返回结果表。
看似简单确做得十分坎坷,首先这是我第一次的答案:
select
product_id,product_name
from Product
where product_id in(
select product_id from Sales where sale_date not between "