2 Replies Latest reply: Jan 18, 2018 4:53 AM by souad ouertani RSS

    sorting data

    souad ouertani

      i Used this script to sort client for each agency and load only the 20 first

      agence:

      LOAD distinct

        agenc

         

      FROM

      [C:\Users\90160\Desktop\hautde gamme\clientHG.qvd]

      (qvd);



      for vRow = 1 to NoOfRows('agence')

      Let MyVar = Peek('agenc',vRow-1,'agence');

      first 20

      HGFINAL:

      load *

      FROM

      [C:\Users\90160\Desktop\hautde gamme\FINAL.qvd]

      (qvd)


      Where AGENCE = '$(MyVar)'

      order by PNB ;

       


      Next

       

      But nothing changed

        • Re: sorting data
          Gysbert Wassenaar

          You can use the Order By clause only on resident loads. So you first need to load the data in a temporary table. Then you can do a resident load from that temporary table and use the Order By to sort it.

           

          agence:

          LOAD distinct

               %ID_AGENCE_CTOS_CLIENT

          FROM

               [C:\Users\90160\Desktop\hautde gamme\clientHG.qvd]

               (qvd)

               ;

           

          Temp:

          LOAD

              *

          FROM

              [C:\Users\90160\Desktop\hautde gamme\HGFINAL.qvd]

              (qvd)

          WHERE

               Exists(%ID_AGENCE_CTOS_CLIENT )

              ;


          DROP TABLE agence;


          Result:

          LOAD

               *

          WHERE

               Counter <= 20;

          LOAD

               *,

              AutoNumber(RecNo(), %ID_AGENCE_CTOS_CLIENT) as Counter

          RESIDENT

               Temp

          ORDER BY

                %ID_AGENCE_CTOS_CLIENT,

               PNB

               ;


          DROP TABLE Temp;

          DROP Field Counter;