Calcular o tempo médio
12/03/2020
0
A query que utilizei para ver se trás as infos corretas foi:
SELECT MIN(DATA_HORA) AS DATA_INI, MAX(DATA_HORA) AS DATA_FIM
FROM INVENTARIO_HISTORICO
Já tentei utilizar o AVG para tirar a media não deu certo, e última observação é que não posso exibir as colunas de DATA_INI e DATA-FIM, apenas a TEMPO_MEDIO.
Andrey Cesar
Posts
12/03/2020
Stella Oliveira
SELECT CAST(CAST(CAST(CAST(E3TimeStamp as float)*1440 as bigint) as float)/1440 as datetime) as Minuto, AVG(Campo) as Média FROM Tabela GROUP BY CAST(CAST(CAST(CAST(E3TimeStamp as float)*1440 as bigint) as float)/1440 as datetime)
– Médias por hora:
SELECT CAST(CAST(CAST(CAST(E3TimeStamp as float)*24 as bigint) as float)/24 as datetime) as Hora, AVG(Campo) as Média FROM Tabela GROUP BY CAST(CAST(CAST(CAST(E3TimeStamp as float)*24 as bigint) as float)/24 as datetime)
– Médias por dia:
SELECT CAST(FLOOR(CAST(E3TimeStamp as float)) as datetime) as Dia, AVG(Campo) as Média FROM Tabela GROUP BY CAST(FLOOR(CAST(E3TimeStamp as float)) as datetime)
12/03/2020
Emerson Nascimento
13/03/2020
Andrey Cesar
SELECT U.NOME AS NOME DO USUARIO, Q1.INTERVALO / Q1.QTD AS MEDIA
FROM USUARIO U
LEFT JOIN
(SELECT ID_[CAMPO], ID_[CAMPO], MAX(DATA_HORA) - MIN(DATA_HORA) AS INTERVALO, COUNT(*) AS QTD
FROM [TABELA]
GROUP BY 1,2) Q1
Clique aqui para fazer login e interagir na Comunidade :)