SQL returning full objects (*) from distincted columns

73 views Asked by At

I am looking for a solution concerning SQL Query for Oracle DB what returns DISTINCT full objects from many columns e.g:

SELECT DISTINCT mt.column1, mt.column2, mt.column3 FROM MyTable mt;

But I need full objects like SELECT * FROM MyTable

Is there any way to obtain such effect using usual SQL statements?

Thanks in advance! :)

1

There are 1 answers

1
shA.t On BEST ANSWER

I think you are looking for a query like this:

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;