19. Count signups within a time range

“Well, the hype is going down”, said Gessica, “I see fewer articles and tweets about Bindle, we should think about starting a marketing department. Let’s see how many users signed up for Bindle within the first week after the website’s launch.”

Finally, we can calculate how many signups Bindle had within the first week after launch. A couple of reminders:

  • Bindle’s website was launched on January 1, 2018
  • The format for date strings is YYYY-MM-DD (year-month-date), 2nd of March would be 2018-03-02
⚠ Type SQL queries in the SQL Editor ☝ to find the answer to this exercise. Do your research in the SQL Editor and then submit numeric or text answer via this form. ⚠

Hint

We’ve just learned how to combine filters. We can get the correct answer by writing a query that translates to “Count all user records which has signup date greater than 1 Jan 2018 and less than 7 Jan 2018”.

⚠ Remember inclusive and non-inclusive comparison operators: signup_date < '2018-01-07' won’t count signups for the 7th of January (less than < operator is non-inclusive).

Solution

SELECT
  COUNT(*)
FROM users
WHERE
  signup_date >= '2018-01-01' 
  AND signup_date <= '2018-01-07'

Anatoli Makarevich, author of SQL Habit About SQL Habit

Hi, it’s Anatoli, the author of SQL Habit. 👋

SQL Habit is a course (or, as some of the students say, “business simulator”). It’s based on a story of a fictional startup called Bindle. You’ll play a role of their Data Analyst 📊 and solve real-life challenges from Business, Marketing, and Product Management.

SQL Habit course is made of bite-sized lessons and exercises (you’re looking at one atm). They always have a real-life setting and detailed explanations. You can immediately apply everything you’ve learned at work. 🚀

“well worth the money”

Fluent in SQL in a month

Master Data Analysis with SQL with real life examples from Product Management, Marketing, Finance and more.
-- Type in your query here. You might want to start by listing all records: SELECT * FROM users
LIMIT 500
Loading chart... ⏳