SELECT
A.year,
A.month,
A.user,
B.user,
A.num - B.num AS num,
case
when A.num > B.num THEN A.user
WHEN A.num < B.num THEN B.user
ELSE '一样大'
END AS result
FROM
table AS A
INNER JOIN table AS B ON A.year = B.year
AND A.month = B.month
AND A.user <> B.user