Assuming there can be no duplicate server names per date, you could try the following:
WITH allservers AS (
SELECT DISTINCT SERVERNAME AS GroupingName
FROM YourTable
WHERE DATE IN (@yesterday, @today)
)
SELECT s.GroupingName, x.*
FROM allservers AS s
LEFT JOIN YourTable AS y ON s.GroupingName = y.SERVERNAME AND y.DATE = @yesterday
LEFT JOIN YourTable AS t ON s.GroupingName = t.SERVERNAME AND t.DATE = @today
CROSS APPLY (
SELECT @yesterday AS GroupingDate, y.*
UNION ALL
SELECT @today AS GroupingDate, t.*
) x
WHERE EXISTS (
SELECT y.CPUs, y.RAM, y.DISK
EXCEPT
SELECT t.CPUs, t.RAM, t.DISK
)
ORDER BY s.GroupingName, x.GroupingDate;
The output produced by this query doesn't match yours exactly but can be easily adjusted in the main SELECT clause. The main purpose of the two columns added, GroupingName
and GroupingDate
, is to keep relevant rows together and in a specific order (yesterday's row followed by today's).
You can play with a live demo of the query at SQL Fiddle.