Solutions
LeetCode
LeetCode
  • Introduction
  • Problems
    • Algorithms
      • Easy
        • 844. Backspace String Compare
        • 905. Sort Array By Parity
    • Database
      • Easy
        • #175 Combine Two Tables
        • #181 Employees Earning More Than Their Managers
        • #182 Duplicate Emails
        • #183 Customers Who Never Order
        • #196 Delete Duplicate Emails
        • #197 Rising Temperature
        • #511 Game Play Analysis I
        • #584 Find Customer Referee
        • #586 Customer Placing the Largest Number of Orders
        • #595 Big Countries
        • #596 Classes More Than 5 Students
        • #607 Sales Person
        • #620 Not Boring Movies
        • #627 Swap Salary
        • #1050 Actors and Directors Who Cooperated At Least Three Times
        • #1084 Sales Analysis III
        • #1141 User Activity for the Past 30 Days I
        • #1148 Article Views I
        • #1179 Reformat Department Table
        • #1407 Top Travellers
        • #1484 Group Sold Products By The Date
        • #1527 Patients With a Condition
        • #1581 Customer Who Visited but Did Not Make Any Transactions
        • #1587 Bank Account Summary II
        • #1667 Fix Names in a Table
        • #1693 Daily Leads and Partners
        • #1729 Find Followers Count
        • #1741 Find Total Time Spent by Each Employee
        • #1757 Recyclable and Low Fat Products
        • #1795 Rearrange Products Table
        • #1873 Calculate Special Bonus
        • #1890 The Latest Login in 2020
        • #1965 Employees With Missing Information
      • Medium
        • #176 Second Highest Salary
        • #177 Nth Highest Salary
    • Shell
      • Easy
        • #193 Valid Phone Numbers
        • #195 Tenth Line
Powered by GitBook
On this page

Was this helpful?

  1. Problems
  2. Database
  3. Easy

#1141 User Activity for the Past 30 Days I

Previous#1084 Sales Analysis IIINext#1148 Article Views I

Last updated 3 years ago

Was this helpful?

SELECT activity_date as day, COUNT(DISTINCT(user_id)) as active_users
FROM Activity 
WHERE activity_date BETWEEN DATEADD(dd, -30, '2019-07-28') AND '2019-07-27'
GROUP BY activity_date
https://leetcode.com/problems/user-activity-for-the-past-30-days-i/