SELECT 
    t1.fecha,
    t1.total - COALESCE(t2.total, 0) AS resultado
FROM 
    (SELECT DATE_FORMAT(fecha, "%Y-%m-%d") AS fecha, SUM(app_ventas.total) AS total
     FROM app_ventas
     WHERE app_ventas.estado = 1 AND DATE(fecha) = '2025-01-04'
     GROUP BY DATE_FORMAT(fecha, "%Y-%m-%d")) t1
LEFT JOIN 
    (SELECT DATE_FORMAT(fecha, "%Y-%m-%d") AS fecha, SUM(valor_egreso) AS total
     FROM app_egresos
     WHERE DATE(fecha) = '2025-01-04'
     GROUP BY DATE_FORMAT(fecha, "%Y-%m-%d")) t2
ON t1.fecha = t2.fecha;