SELECT
COALESCE(a.id,t.AppointmentId) AS Id,
COALESCE(a.AppointmentTotal,0) AS AppointmentTotal,
COALESCE(SUM(t.total),0) AS TotalsTotal
FROM
Appointments a
FULL JOIN Totals t ON
t.AppointmentId = a.id
GROUP BY
COALESCE(a.AppointmentTotal,0),
COALESCE(a.id,t.AppointmentId)
HAVING
COALESCE(a.AppointmentTotal,0) <> COALESCE(SUM(t.total),0)