SELECT xml.data AS giorno
, xml.matricola AS matricola
, REPLACE(SUBSTR(IFNULL(xml.ora_inizio,'00:00'),1,5),':','') AS ora_entrata
, REPLACE(SUBSTR(IFNULL(xml.ora_fine,'00:00'),1,5),':','') AS ora_uscita
, CAST(IFNULL(xml.ore_teoriche,0) AS DECIMAL(12,2)) AS ore_teoriche
, CAST(IFNULL(xml.ore_notturne,0) AS DECIMAL(12,2)) AS ore_notturne
, CAST(IFNULL(xml.ore_assenza,0) AS DECIMAL(12,2)) AS ore_assenza
, IFNULL(xml.causale_assenza,'') AS causale_assenza
FROM xml_turni AS xml
ORDER BY codfisc, data, ora_inizio