У меня есть следующий запрос:
SELECT MATRICULE,ID_POINTAGE,DT_POINTAGE,HH_POINTAGE,CONVERT(VARCHAR,DATEADD(SS,HH_POINTAGE,8),108) GMT,ROW_NUMBER() OVER(PARTITION BY MATRICULE,DT_POINTAGE ORDER BY MATRICULE , DT_POINTAGE) AS NEMRA,CASE WHEN ROW_NUMBER() OVER(PARTITION BY MATRICULE,DT_POINTAGE ORDER BY MATRICULE , DT_POINTAGE) % 2 = 1 THEN 'S' ELSE 'E' END ENTREE_SORTIE FROM POINTAGES WHERE MATRICULE = '0118' AND DT_POINTAGE = '30/10/2019'AND HH_POINTAGE NOT IN ((SELECT MAX(HH_POINTAGE) FROM POINTAGES WHERE MATRICULE = '0118' AND DT_POINTAGE = '30/10/2019'),(SELECT MIN(HH_POINTAGE) FROM POINTAGES WHERE MATRICULE = '0118' AND DT_POINTAGE = '30/10/2019'))
--Formatted Query
SELECT MATRICULE,
ID_POINTAGE,
DT_POINTAGE,
HH_POINTAGE,
CONVERT(varchar, DATEADD(SS, HH_POINTAGE, 8), 108) AS GMT,
ROW_NUMBER() OVER (PARTITION BY MATRICULE, DT_POINTAGE ORDER BY MATRICULE, DT_POINTAGE) AS NEMRA,
CASE
WHEN ROW_NUMBER() OVER (PARTITION BY MATRICULE, DT_POINTAGE ORDER BY MATRICULE, DT_POINTAGE) % 2 = 1 THEN 'S'
ELSE 'E'
END AS ENTREE_SORTIE
FROM POINTAGES
WHERE MATRICULE = '0118'
AND DT_POINTAGE = '30/10/2019'
AND HH_POINTAGE NOT IN ((SELECT MAX(HH_POINTAGE)
FROM POINTAGES
WHERE MATRICULE = '0118'
AND DT_POINTAGE = '30/10/2019'), (SELECT MIN(HH_POINTAGE)
FROM POINTAGES
WHERE MATRICULE = '0118'
AND DT_POINTAGE = '30/10/2019'));
Я получаю эти результаты:
Мой вопрос, если естьВ любом случае я могу выполнить следующую операцию над столбцом HH_POINTAGE
: (32820 - 32400) + (42000 - 41400) + (50400 - 43200)