篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql viajes por rango de hora相关的知识,希望对你有一定的参考价值。
SELECT date(ap.created_dt),ap.mas_id,m.email,m.first_name,
COUNT(
CASE
WHEN ap.status = 5 and hour(ap.created_dt)>=12 and hour(ap.created_dt)<16 THEN 1
END
) as cancelados_conductor,
COUNT(
CASE
WHEN ap.status = 9 and hour(ap.created_dt)>=12 and hour(ap.created_dt)<16 THEN 1
END
) as completados
,
COUNT(
CASE
WHEN ap.status = 10 and hour(ap.created_dt)>=12 and hour(ap.created_dt)<16 THEN 1
END
) as ignorados_conductor
,
COUNT(
CASE
WHEN ap.status = 3 and hour(ap.created_dt)>=12 and hour(ap.created_dt)<16 THEN 1
END
) as rechazados
,
COUNT(
CASE
WHEN ap.status = 14 and hour(ap.created_dt)>=12 and hour(ap.created_dt)<16 THEN 1
END
) as aceptados_despues_aceptados
,
COUNT(
CASE
WHEN ap.status = 4 and hour(ap.created_dt)>=12 and hour(ap.created_dt)<16 THEN 1
END
) as cancelados_pasajero
FROM `appointment` as ap LEFT join master as m on ap.mas_id=m.mas_id
WHERE ap.status in (9,5,10,3,14,4) and ap.created_dt >= '2018-12-27 00:00:00' AND ap.created_dt<='2019-01-02 23:59:59'
GROUP BY date(ap.created_dt), ap.mas_id
以上是关于sql viajes por rango de hora的主要内容,如果未能解决你的问题,请参考以下文章