Leetcode SQL

601. Human Traffic of Stadium

X city built a new stadium, each day many people visit it and the stats are saved as these columns: id, visit_date, people

Please write a query to display the records which have 3 or more consecutive rows and the amount of people more than 100(inclusive).

For example, the table stadium:

For the sample data above, the output is:

Each day only have one row record, and the dates are increasing with id increasing.


  1. If not using to_char(visit_date, ‘YYYY-MM-DD’) the visit_date would have time. So be sure to use to_char(,’YYYY-MM-DD’)
  2. order by id, visit_date. Testing showed without visit_date, it would still work. But to play safe, remember to order by id, visit_date.





Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store