SELECT HOUR(cre_dat) AS ora, COUNT(id) AS tot, SUM(totale_da_incassare) AS tot FROM tb_prenotazioni WHERE DATE(cre_dat) = '2024-08-13' AND cancellato = 'N' GROUP BY HOUR(cre_dat) UNION SELECT 'totale' AS ora, COUNT(id) AS tot, SUM(totale_da_incassare) FROM tb_prenotazioni WHERE DATE(cre_dat) = '2024-08-21' AND cancellato = 'N' ; SELECT tb_prenotazioni.id, titoloEN, tb_eventi_date.data, tb_eventi_date.ora, codice_prenotazione, persone, checkin, tb_prenotazioni.cre_dat FROM tb_prenotazioni JOIN tb_eventi_date ON tb_prenotazioni.data_id = tb_eventi_date.id JOIN tb_eventi ON tb_eventi.id = tb_prenotazioni.evento_id WHERE tb_prenotazioni.cancellato = 'N' AND checkin != persone #AND (persone - checkin)>2 AND DATEDIFF(tb_eventi_date.data, tb_prenotazioni.cre_dat) >= 30 AND tb_eventi_date.data< NOW() ; SELECT SUM(persone), SUM(checkin), titoloEN, tb_eventi_date.data, tb_eventi_date.ora, tb_prenotazioni.evento_id, tb_prenotazioni.data_id FROM tb_prenotazioni JOIN tb_eventi_date ON tb_prenotazioni.data_id = tb_eventi_date.id JOIN tb_eventi ON tb_eventi.id = tb_prenotazioni.evento_id WHERE tb_prenotazioni.cancellato = 'N' AND checkin != persone #AND (persone - checkin)>2 #AND DATEDIFF(tb_eventi_date.data, tb_prenotazioni.cre_dat) >= 30 AND tb_eventi_date.data