# query for creating time range

**URL:** <https://forums.percona.com/t/query-for-creating-time-range/4438>\
**Category:** Other MySQL® Questions\
**Created:** [October 8, 2015, 9:46am UTC](https://forums.percona.com/t/query-for-creating-time-range/4438 "2015-10-08T09:46:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhishm](https://avatars.discourse-cdn.com/v4/letter/b/ecd19e/32.png) [@bhishm](https://forums.percona.com/u/bhishm)\
**Post date:** [October 8, 2015, 9:46am UTC](https://forums.percona.com/t/query-for-creating-time-range/4438/1 "2015-10-08T09:46:18Z")

</div>

In the school different staff come at different time.

* * *

## NAME | Date | INTIME | OUTIME

## A | 2015-10-08 | 08:00:00 | 18:00:00

## B | 2015-10-08 | 10:00:00 | 14:00:00

## C | 2015-10-08 | 15:00:00 | 18:00:00

## We want output like this

## Date | Time Range | People Present

## 2015-10-08 | 08-09 | 1

## 2015-10-08 | 09-10 | 1

## 2015-10-08 | 10-11 | 2

## 2015-10-08 | 11-12 | 2

## 2015-10-08 | 12-13 | 2

## 2015-10-08 | 13-14 | 2

## 2015-10-08 | 14-15 | 3

How can we generate such an output through query.
