SET @date_limite = DATE_ADD(NOW(), INTERVAL -1 DAY);

SELECT @moyenne_globale:=AVG(note_principale) 
    FROM borne_avis 
    WHERE date > @date_limite;

SELECT @moyenne_borne:=AVG(note_principale) 
    FROM borne_avis 
    JOIN sources ON sources.id = borne_avis.source_id
    WHERE date > @date_limite AND sources.nom = "borne";

SELECT @moyenne_site:=AVG(note_principale)
    FROM borne_avis 
    JOIN sources ON sources.id = borne_avis.source_id
    WHERE date > @date_limite AND sources.nom = "website";

INSERT INTO stats_jour (moyenne_globale, moyenne_borne, moyenne_site) VALUES (@moyenne_globale, @moyenne_borne, @moyenne_site);