6
SELECT COUNT(*) AS contador, hora_efetivada FROM minha_tabela WHERE status=2
I have a counter that returns the total value of status 2 in the database, but in my name column hora_efetivada
there are several times. How do I make for my select
return the first time and last time?
For example:
|status| hora_efetivada
| 2 | 13:10
| 2 | 13:12
| 2 | 12:01
| 2 | 08:03
| 2 | 18:03
| 2 | 13:03
My SELECT would return COUNT = 6
and the two times (08:03
and 13:13
).
I’ll have to implement it another way?
SELECT COUNT(*) AS contador, MIN(hora_efetivada) as primeiro_horario, MAX(hora_efetivada) as ultimo_horario FROM minha_tabela WHERE status=2
As long as the spine is the type TEAM, otherwise it will be necessary to make aCAST
.– Marcos Regis
SELECT 
 COUNT(STATUS) AS TOTAL,
 STATUS,
 SELECT SUBSTRING(HORA_EFETIVADA,-3);
 FROM
 MINHA_TABELA
 GROUP BY
 STATUS
– Diego Souza