为什么我Jim
在以下结果中得到重复?
CREATE TABLE #B (Name VARCHAR(10), Age INT)
INSERT INTO #B
values
('Jim', 21),
('Jim', 21),
('Jim', 19),
('Jim', 20),
('Nick', 20),
('Nick', 2),
('Nick', 20);
SELECT DISTINCT
Name,
Age
FROM #B A
WHERE EXISTS
(
SELECT 1
FROM #B B
WHERE A.Age > B.Age
AND A.NAME = B.NAME
)