GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — LeetCode-Solutions/MySQL/active-users.sql at master · basketscript/LeetCode-Solutions

Expand file tree

/

active-users.sql

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
34 lines (33 loc) · 899 Bytes
/

active-users.sql

Copy path

File metadata and controls

34 lines (33 loc) · 899 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Time: O(nlogn)
# Space: O(n)
SELECT DISTINCT
r.id,
r.name
FROM
(SELECT a_l.id,
a_l.name,
@accu := CASE
WHEN a_l.name = @prev AND
DATEDIFF(a_l.login_date, @login_date) = 1
THEN @accu + 1
ELSE 1
END AS accu,
@prev := a_l.name AS prev,
@login_date := a_l.login_date AS login_date
FROM (
(SELECT DISTINCT
a.id,
a.name,
l.login_date
FROM accounts a
LEFT JOIN logins l
ON a.id = l.id
ORDER BY a.id,
a.name,
l.login_date) a_l,
(SELECT @accu := 0,
@prev := "",
@login_date := "") init
)
) r
WHERE r.accu = 5;
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.