答案 0 :(得分:1)
使用Cte:
;WITH cte
AS (SELECT *,
Row_number()
OVER(
partition BY relationfamily
ORDER BY lastmodify DESC) AS result
FROM User_Relation)
SELECT relationfamily,
lastmodify
FROM cte
WHERE result = 1
答案 1 :(得分:0)
检查以下查询,希望这可以帮助您:
SELECT relationfamily, MAX(lastmodify)
FROM User_Relation
WHERE mainuser = 'sivabrahma'
GROUP BY relationfamily