bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 1454. Active Users

1454. Active Users

Leetcode Solutions

Using Window Functions to Identify Active Users

  1. Use the DENSE_RANK() window function to assign a rank to each login date for each user, ordered by the login date.
  2. Subtract the rank from the login date to create a grouping identifier for consecutive login dates.
  3. Group by the user id and the grouping identifier, and count the number of unique login dates in each group.
  4. Filter the groups to only include those with five or more unique login dates.
  5. Join the filtered result with the Accounts table to get the user names.
  6. Select the distinct user ids and names from the result.
  7. Order the final result by user id.
erDiagram
    Accounts {
        int id PK
        varchar name
    }
    Logins {
        int id FK >- Accounts.id
        date login_date
    }

Using Self-Join to Identify Active Users

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...
bugfree Icon
OR