3 Replies Latest reply on Aug 18, 2015 8:35 PM by rp0428

    Need help to write one sql

    976410


      Hi Team,

       

      Need your help to write one sql query to fetch data from oracle table.

      I've one table RATINGS and data looks like this.

       

      FIELD1     FIELD2                FIELD3

      -1              Title 1              2/8/2013

      13020        Title 2              4/4/2013

      -1               Title 1              4/25/2013

      -1               Title 1              9/17/2013

      -1               Title 1              9/25/2013

      -1               Title 1              5/14/2014

      13020       Title 2              5/14/2014

      -1               Title 1              7/9/2014

      12726       Title 3              11/26/2014

      12726       Title 3              1/22/2015

       

      From above data i need those data which were changed. Like below.

      FIELD1     FIELD2                FIELD3

      -1              Title 1              2/8/2013

      13020      Title 2              4/4/2013

      -1              Title 1              4/25/2013

      13020      Title 2              5/14/2014

      -1              Title 1              7/9/2014

      12726      Title 3              11/26/2014

       

      Please help. Thanks in Advance.

        • 1. Re: Need help to write one sql
          923455

          Requirement is not clear.

          example:

          -1, Title1 has repeated many times. So we can assume it has changed again and again. So do you need one of such record (either first or last) or all of them? How to different -1, Title from -1, Title?? And same question with 13020      Title 2

          • 2. Re: Need help to write one sql
            976410


            Hi,

            Data is changing from -1 to 13020 to again -1 and agin to 13020 and so on. Here i need first time when it get changed. from -1 to 13020 likewise for all records. I have ID field also which is primary key but i didn't add that here. This is history table and i trying to find out on which dates values got changed.

             

            ID     FIELD1     FIELD2                FIELD3

            101     -1         Title 1              2/8/2013

            102     13020       Title 2              4/4/2013

            103     -1          Title 1              4/25/2013

            104     -1          Title 1              9/17/2013

            105     -1          Title 1              9/25/2013

            106     -1          Title 1              5/14/2014

            107     13020       Title 2              5/14/2014

            108     -1          Title 1              7/9/2014

            109     12726       Title 3              11/26/2014

            110     12726       Title 3              1/22/2015

            • 3. Re: Need help to write one sql

              Need your help to write one sql query to fetch data from oracle table.

              Then you need to post your question/issue in the Sql and Pl/Sql forum.

              SQL & PL/SQL

               

              This forum is ONLY for Sql Developer questions.

               

              Please mark the thread ANSWERED and post in the other forum.