SQL 实现要求连续三天以及以上,并且每天人流量不少于100

with t1 as  (
	select id, `date` as dt, row_number() as num_id, people from stadium
) , t2 as (
	select id, `date` as dt, row_number() as num_id, people from stadium
) , t3 as (
	select id, `date` as dt, row_number() as num_id, people from stadium
) 
seelct t1.id, t1.dt, t1.people from t1 join t2 on (t1.num_id + 1) = t2.num_id join t3 
on (t2.num_id + 1) = t3.num_id where t1.people > 100 and t2.peopel > 100 and t3.people > 100 order by t1.id




SQL 实现要求连续三天以及以上,并且每天人流量不少于100_第1张图片

你可能感兴趣的:(SQL,LeetCode)