2 Replies Latest reply on May 26, 2016 3:06 PM by S Paul RJ

    SQL Query

    2836031

      Hello Friends,

       

      Can you please help me, how to find duplicates by using only rownum?

       

      Thanks in Advance...

        • 1. Re: SQL Query
          kulikouski

          Hi,
          No, that is not possible.
          "For each row returned by a query, the ROWNUM pseudocolumn returns a number indicating the order in which Oracle selects the row from a table or set of joined rows. The first row selected has a ROWNUM of 1, the second has 2, and so on."
          So it means that rownum is not a part of data but just a number of record in resultset (it could be treated as unique).

           

          To find duplicates you have to have a condition of duplicate (f.e. a name meets twice).

           

          Best Regards

          • 2. Re: SQL Query
            S Paul RJ

            Hi,

             

                      Try this,

             

                      select *

                         from (select *,

                                               row_number() over (partition by emp_name ORDER BY employee_id)  rn

                                      from emp)

                      where rn>1;

             

            Regards,

            S Paul RJ