// advent-of-postgres/day-16
The Error of the Hour
One bad hour can make an error code look like the biggest problem of the day. Find the code that leads the most hours instead.
The error dashboard shows one huge bar for 16 December, and Bushy wants to fix that error first. Tinsel is not so sure. "One bad hour does not make a pattern," Tinsel says. "Which error is the problem hour after hour?"
Every error on 16 December is in errors:
| Column | Type | Notes |
|---|---|---|
id |
bigint |
Primary key |
occurred_at |
timestamptz |
When it happened |
code |
text |
For example E429 or E503 |
For each hour of the day (UTC), the error of the hour is the code that occurred most often in that hour. If two codes tie in an hour, the code that sorts first alphabetically wins that hour.
Your task
Which code was the error of the hour in the most hours?
Submit the code.
Stuck? Show a hint
mode() WITHIN GROUP (ORDER BY code) gives the most common code per group, and picks the code that sorts first on a tie. Group by date_trunc('hour', occurred_at, 'UTC') first, then count the winners.
Download today's data as SQL to solve it on your own Postgres (14 or later).
Solved this puzzle? Share it.
Tag @thedevopsdaily and share it with the community.
We earn commissions when you shop through the links below.
Bitrise
Managed runners for GitHub Actions
Bitrise Build Hub runs your GitHub Actions jobs on M4 Macs and AMD Linux machines. Change runs-on and keep your workflows, secrets and logs on GitHub.
Atomsized
AWS platform engineering and GitOps
Design and automation for reliable AWS and Kubernetes platforms, safer delivery workflows, and preview and UAT environments your engineers can understand and own.
DigitalOcean
Cloud infrastructure for developers
Simple, reliable cloud computing designed for developers
DevDojo
Developer community & tools
Join a community of developers sharing knowledge and tools
SMTPfast
Developer-first email API
Send transactional and marketing email through a clean REST API. Detailed logs, webhooks, and embeddable signup forms in one dashboard.
QuizAPI
Developer-first quiz platform
Build, generate, and embed quizzes with a powerful REST API. AI-powered question generation and live multiplayer.
Want to support DevOps Daily and reach thousands of developers?
Become a Sponsor