Récupérer le MIN du STA1.DH_ALERTE_ENGIN [Fermé]

Signaler
Messages postés
47
Date d'inscription
mercredi 3 juillet 2013
Statut
Membre
Dernière intervention
30 mars 2021
-
SELECT DISTINCT
COUNT(STA.[NUMERO_INTER_RI]) AS Nbre_Inter ,
CASE WHEN CONVERT(VARCHAR,( STA1.[DH_LIEUX_ENGIN] -STA1.DH_ALERTE_ENGIN),108)< '00:05:00' THEN '< 5 mn'
WHEN CONVERT(VARCHAR,( STA1.[DH_LIEUX_ENGIN] - STA1.DH_ALERTE_ENGIN),108) BETWEEN '00:05:00' AND '00:10:00' THEN '>= 5 & < 10 mn' WHEN CONVERT(VARCHAR,( STA1.[DH_LIEUX_ENGIN] - STA1.DH_ALERTE_ENGIN),108) BETWEEN '00:10:00' AND '00:15:00' THEN '>= 10 & < 15 mn'
WHEN CONVERT(VARCHAR,( STA1.[DH_LIEUX_ENGIN] - STA1.DH_ALERTE_ENGIN),108) BETWEEN '00:15:00' AND '00:20:00' THEN '>= 15 & < 20 mn'
WHEN CONVERT(VARCHAR,( STA1.[DH_LIEUX_ENGIN] - STA1.DH_ALERTE_ENGIN),108) BETWEEN '00:20:00' AND '00:25:00' THEN '>= 20 & < 25 mn'
WHEN CONVERT(VARCHAR,( STA1.[DH_LIEUX_ENGIN] - STA1.DH_ALERTE_ENGIN),108) > '00:25:00' THEN '> 25 mn' END
AS Interv_Delai ,
STA3.[NOM_CATEGORIE_SINISTRE] AS Categorie
FROM
((([ODS_DEV].[dbo].[STA_RAPPORT_INTERVENTION] STA INNER JOIN [ODS_DEV].[dbo].[STA_ENGIN_RI] STA1 ON STA.[ANNEE_INTER_RI] = STA1.[ANNEE_INTER_RI] and STA.[NUMERO_INTER_RI] = STA1.[NUMERO_INTER_RI] and STA.[NUMERO_RENFORT_RI] = STA1.[NUMERO_RENFORT_RI]) INNER JOIN [ODS_DEV].[dbo].[STA_CENTRE] STA2 ON STA1.[NUMERO_CENTRE] = STA2.[NUMERO_CENTRE]) INNER JOIN [ODS_DEV].[dbo].[STA_SINISTRE_ARBRE] STA3 ON STA.[NOM_SINISTRE] = STA3.[NOM_SINISTRE])
WHERE
STA.[ANNEE_INTER_RI] = 13
AND (STA1.[INTITULE_ENGIN] LIKE 'EPS %'
OR STA1.[INTITULE_ENGIN] LIKE 'BEA')
AND STA.[NOMCOMMUNE_IDENT] NOT LIKE 'Z-%'
AND ( STA1.[DH_LIEUX_ENGIN] -STA1.DH_ALERTE_ENGIN) IS NOT NULL
AND STA2.[NOM_CENTRE] NOT LIKE 'Z-%'
GROUP BY CASE WHEN CONVERT(VARCHAR,( STA1.[DH_LIEUX_ENGIN] -STA1.DH_ALERTE_ENGIN),108)< '00:05:00' THEN '< 5 mn'
WHEN CONVERT(VARCHAR,( STA1.[DH_LIEUX_ENGIN] - STA1.DH_ALERTE_ENGIN),108) BETWEEN '00:05:00' AND '00:10:00' THEN '>= 5 & < 10 mn' WHEN CONVERT(VARCHAR,( STA1.[DH_LIEUX_ENGIN] - STA1.DH_ALERTE_ENGIN),108) BETWEEN '00:10:00' AND '00:15:00' THEN '>= 10 & < 15 mn'
WHEN CONVERT(VARCHAR,( STA1.[DH_LIEUX_ENGIN] - STA1.DH_ALERTE_ENGIN),108) BETWEEN '00:15:00' AND '00:20:00' THEN '>= 15 & < 20 mn'
WHEN CONVERT(VARCHAR,( STA1.[DH_LIEUX_ENGIN] - STA1.DH_ALERTE_ENGIN),108) BETWEEN '00:20:00' AND '00:25:00' THEN '>= 20 & < 25 mn'
WHEN CONVERT(VARCHAR,( STA1.[DH_LIEUX_ENGIN] - STA1.DH_ALERTE_ENGIN),108) > '00:25:00' THEN '> 25 mn' END


,STA3.[NOM_CATEGORIE_SINISTRE]

Je n'arrive pas à récupérer le minimum de ma date et heure d'alerte, sachant que 2 engins peuvent être alerter à 5 mn d'intervalle.
J'ai essayé MIN(STA1.DH_ALERTE_ENGIN)

Merci par avance