select id,visit_date,people from( select *, lag(people,1) over(order by id)l1, lag(people,2)over(order by id) l2, lead(peopl...
select round( ifnull( 1/(count( distinct f1.sender_id,f1.send_to_id) /count(distinct r1.requester_id,r1...
select class from courses group by 1 having count(distinct student)>=5
select c.country_name, case when avg(w.weather_state)<=15 then "Cold" when avg(w.weather_state)<25 then "Warm" else "Hot" end weather_type...
select name,population,area from world where area>3000000 or population>25000000
select customer_number from orders group by 1 order by count(*) desclimit 0,1
select round(sum(tiv_2016),2) tiv_2016 from (select *,count(*) over(partition by tiv_2015) a1,count(*) over(partition by lat,lon) a2 from insurance) as...
select name from customer where referee_id <>2 or isnull(referee_id)
select dept_name,count(student_id) student_number from department d left join student s on d.dept_id=s.dept_id group by dept_name order by 2 d...