1225. Report Contiguous Dates

https://leetcode.com/problems/report-contiguous-dates

Description

Table: Failed

+--------------+---------+
| Column Name  | Type    |
+--------------+---------+
| fail\_date    | date    |
+--------------+---------+
Primary key for this table is fail\_date.
Failed table contains the days of failed tasks.

Table: Succeeded

+--------------+---------+
| Column Name  | Type    |
+--------------+---------+
| success\_date | date    |
+--------------+---------+
Primary key for this table is success\_date.
Succeeded table contains the days of succeeded tasks.

A system is running one task every day. Every task is independent of the previous tasks. The tasks can fail or succeed.

Write an SQL query to generate a report of period_state for each continuous interval of days in the period from 2019-01-01 to 2019-12-31.

period_state is *'failed'*if tasks in this interval failed or 'succeeded' if tasks in this interval succeeded. Interval of days are retrieved as start_date and end_date.

Order result by start_date.

The query result format is in the following example:

ac

Last updated

Was this helpful?