我正在寻找一个关于SQL Query for Oracle DB的解决方案,它从许多列返回DISTINCT 完整对象,例如:
SELECT DISTINCT mt.column1, mt.column2, mt.column3 FROM MyTable mt;
但我需要像SELECT * FROM MyTable
有没有办法使用通常的SQL语句来获得这样的效果?
提前致谢! :)
答案 0 :(得分:1)
我认为您正在寻找这样的查询:
SELECT *
FROM (
SELECT
*, ROW_NUMBER() OVER (PARTITION BY mt.column1, mt.column2, mt.column3 ORDER BY mt.column1, mt.column2, mt.column3) As Seq
FROM
MyTable mt) AS DT
WHERE
Seq = 1;