Rush Hour

SQL practice problem 12 of 67 · Text & Dates · Medium · 25 coins for your first accepted solve

When do players log in? For every hour of the day that has at least one login, return hour (an integer from 0 to 23) and the number of logins in that hour as logins.

Sort by hour.

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: Weekend Warriors · Next: Weekly Sales · All problems