2017-01-02 42 views

回答

1

您可以使用聚集和UNION ALL這樣的:

SELECT name FROM t GROUP BY name HAVING COUNT(*) <= 2 
UNION ALL 
SELECT name 
FROM t 
WHERE name NOT IN 
    (SELECT name FROM t GROUP BY name HAVING COUNT(*) <= 2 
); 
+0

非常感謝你 – George312