SELECT asodocumento, asonombres, asoapellidos, (casocompensacionbasica/240) as precio_por_hora, 
count(*) as total_nocturnas ,
round(casocompensacionbasica/240*0.4*count(*)) as costo
FROM `sfet_turnoasociado` 
inner join sfet_contratoasociado on contratoasociado_id = turcontratoasociado
inner join sfet_asociado on asociado_id = casoasociado
where turfechainicio >= "2017-09-01 00:00:00" and turfechainicio <= "2017-09-31 23:59:59"
and turfechasalida >= DATE_FORMAT(turfechainicio, "%Y-%m-%d 22:00:00")
and turfechainicio <= DATE_FORMAT(turfechainicio, "%Y-%m-%d 21:00:00")
and turasistio = "1"
and turhoranocturna >= turhoranocturnafestiva
and turtotalhoras > 0
group by turcontratoasociado

-----------

SELECT asodocumento, asonombres, asoapellidos, (casocompensacionbasica/240) as precio_por_hora, 
count(*) as total_nocturnas ,
round(casocompensacionbasica/240*(2.15)*count(*)) as costo
FROM `sfet_turnoasociado` 
inner join sfet_contratoasociado on contratoasociado_id = turcontratoasociado
inner join sfet_asociado on asociado_id = casoasociado
where turfechainicio >= "2017-09-01 00:00:00" and turfechainicio <= "2017-09-31 23:59:59"
and turfechasalida >= DATE_FORMAT(turfechainicio, "%Y-%m-%d 22:00:00")
and turfechainicio <= DATE_FORMAT(turfechainicio, "%Y-%m-%d 21:00:00")
and turasistio = "1"
and turhoranocturna < turhoranocturnafestiva
and turtotalhoras > 0
group by turcontratoasociado
