J'ai un tableau de rendez-vous (voir ci-dessous)
ID | Start Time | End Time |
1 | 09:00 | 09:45 |
2 | 10:15 | 10:30 |
Ce que je veux faire, c'est sortir un tableau qui montre si chaque enregistrement occupe un créneau horaire de 15 minutes. Le tableau ci-dessus serait donc affiché comme suit :
09:00 - 09:15 | 09:16 - 09:30 | 09:31 - 09:45 | 09:46 - 10:00 | 10:01 - 10:15 | 10:16 - 10:30
ID 1 | ID 1 | ID 1 | | ID 2 | ID 2
Vous avez une idée de par où commencer ?!
EDITAR:
C'est là où je veux en venir, mais je n'ai pas essayé d'inclure les heures de fin ou comment un intervalle de temps qui est couvert par l'heure de début et de fin comme ID 1 dans l'exemple à 09:16 - 09:30 :
SELECT
'09:00 - 09:15' = case when
cast(a_start as time) >= '09:00:00' and cast(a_start as time) < '09:16:00'
then a_id else '' END,
'09:16 - 09:30' = case when
cast(a_start as time) >= '09:16:00' and cast(a_start as time) < '09:30:00'
then a_id else '' END,
'09:31 - 09:45' = case when
cast(a_start as time) >= '09:31:00' and cast(a_start as time) < '09:45:00'
then a_id else '' END,
'09:46 - 10:00' = case when
cast(a_start as time) >= '09:46:00' and cast(a_start as time) < '10:00:00'
then a_idelse '' END
FROM appointments
EDIT 2 :
Maintenant, ça marche un peu :
SELECT
'08:00 - 08:59' = case when
(cast(a_start as time) <= '08:00:00')
AND
(cast(a_end as time) >= '08:59:00')
then a_id else '' END,
'09:00 - 09:15' = case when
(cast(a_start as time) <= '09:00:00')
AND
(cast(a_end as time) >= '09:15:00')
then a_id else '' END,
'09:16 - 09:30' = case when
(cast(a_start as time) <= '09:16:00')
AND
(cast(a_end as time) >= '09:30:00')
then a_id else '' END,
'09:31 - 09:45' = case when
(cast(a_start as time) <= '09:31:00')
AND
(cast(a_end as time) >= '09:45:00')
then a_id else '' END,
'09:46 - 10:00' = case when
(cast(a_start as time) <= '09:46:00')
AND
(cast(a_end as time) >= '10:00:00')
then a_id else '' END,
'10:01 - 10:15' = case when
(cast(a_start as time) <= '10:01:00')
AND
(cast(a_end as time) >= '10:15:00')
then a_id else '' END
FROM appointments