Hot Streak

SQL practice problem 61 of 67 · Boss Fights · Hard · 50 coins for your first accepted solve

A player may log in several times a day. A streak is a run of consecutive calendar days with at least one login.

For every player who logged in at least once, return name and longest_streak (in days). Row order does not matter.

Schema

CREATE TABLE players (
  id         INT PRIMARY KEY,
  name       TEXT NOT NULL,
  country    TEXT,            -- NULL = unknown
  level      INT NOT NULL,
  joined_on  DATE NOT NULL,
  mentor_id  INT              -- another player's id, or NULL
);

CREATE TABLE logins (
  player_id  INT NOT NULL REFERENCES players(id),
  logged_at  TIMESTAMP NOT NULL
);

Write your query in the browser, run it on the sample data, then submit it against hidden test data.

Previous: Monthly Growth · Next: Proud Mentors · All problems