2 Replies Latest reply on Jun 22, 2015 7:28 PM by Vadim Tropashko-Oracle

    connect by with rownum

    2742751

      I am using below query1 to retrive all dates between dates 2012-01-01' to 2012-01-10'

       

      query1:

        select rownum+to_date('2012-01-01','YYYY-MM-DD')-1 rn from dual

        connect by rownum < to_date('2012-01-10','YYYY-MM-DD')-to_date('2012-01-01','YYYY-MM-DD')+2

       

      query2:

      select rownum+to_date('2012-01-01','YYYY-MM-DD')-1 rn from dual

        where rownum <= to_date('2012-01-10','YYYY-MM-DD')-to_date('2012-01-01','YYYY-MM-DD')+2

       

      can anyone explain difference between query1 and query2

        • 1. Re: connect by with rownum
          can anyone explain difference between query1 and query2

          No - not in this forum they can't.

           

          This forum is ONLY for Sql Developer questions/issues.

           

          Please mark the thread ANSWERED and repost your question in the SQL and PL/SQL forum.

          SQL & PL/SQL

           

          And when you repost you need to provide the RESULTS you get from those queries. All you have done above is post two queries and ask what the difference is. For all anyone knows there is NO DIFFERENCE in the results.

          • 2. Re: connect by with rownum
            Vadim Tropashko-Oracle

            Rownum type is number (integer to be more precise). The query difference reduces to:

             

            select rownum from dual

            connect by rownum < 10

             

            vs

             

            select rownum from dual

            connect by rownum <= 10