我对Oracle有一个简单的查询。
SELECT DISTINCT City, Name, Surname FROM Persons
对于没有DISTINCT
的同一查询,是否有任何替代sql查询?
答案 0 :(得分:2)
示例为;
select City
from (
select City,
row_number() over
(partition by City
order by City) rownumber
from Persons
) t
where rownumber = 1
答案 1 :(得分:1)
SELECT City, Name, Surname FROM Persons
UNION
SELECT City, Name, Surname FROM Persons
答案 2 :(得分:0)
SELECT First(City), First(Name), First(Surname)
FROM Persons
GROUP BY City, Name, Surname