SELECT ap.appointment_id as folio,
ap.amount as monto ,
CASE
WHEN ap.status = 9 THEN "Viaje completado"
WHEN ap.status = 5 THEN "cancelado conductor"
WHEN ap.status = 4 THEN "cancelado pasajero"
ELSE "No identificado"
END
as estatus_viaje,
pp.amount as pendiente,
pp.create_dt as fecha,
w.unique_id as unidad,
wt.type_name as tipo,
CASE
WHEN pp.payment_type = 1 THEN "Tarjeta"
WHEN pp.payment_type = 2 THEN "Wallet"
ELSE "No identificado"
END
as "pagado con"
from appointment as ap inner JOIN pending_payment as pp on ap.appointment_id=pp.appointment_id
left join workplace w on ap.car_id= w.workplace_id
left join workplace_types wt on w.type_id = wt.type_id
where pp.create_dt > '2019-05-27 00:00:00' AND pp.create_dt < '2019-06-2 23:59:59' and pp.status=1