# Hive Solution

## 3.Hive Solution

```sql
SELECT 
  x.period_state, -- x.rank_parti-ran,
  min(x.ymd) as start_date,
  max(x.ymd) as end_date
FROM
  (SELECT 
  a.period_state,a.ymd,
  row_number()OVER(partition by a.period_state order by a.ymd ) as rank_parti,
  row_number()OVER(order by a.ymd ) as rank
  FROM
      (select 'failed' as period_state,fail_date as ymd 
      from leetcode.ex_1225_failed
        where year(fail_date)='2019'
      union all 
      select 'succeeded' as period_state,success_date as ymd 
      from  leetcode.ex_1225_succeeded
        where year(success_date)='2019') a 
  ) x  
  GROUP BY x.period_state,x.rank_parti-rank
  ORDER BY x.start_date 
;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://chiu-kuohsin.gitbook.io/leetcode-database-solution-with-hive-sql/exercise-13-1225.report-contiguous-dates/hive-solution.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
