3 Replies Latest reply: Feb 2, 2018 4:32 PM by Haidar HAJ ALI RSS

    Load only first record

    Haidar HAJ ALI

      Hello,

       

      I have a table which I load in via the following script:

       

      [versions]:

      LOAD

      [id_u3] AS [id_u3],

      [name_u2] AS [name_u2],

      [__FK_versions] AS [__KEY_fields]

      RESIDENT RestConnectorMasterTable

      WHERE NOT IsNull([__FK_versions]) ORDER BY [id_u3];

       

      Each [id_u3] have only one [name_u2] but [__KEY_fields] can have multiple reccord of couple ( [id_u3] , [name_u2]):

      Example

       

      [__KEY_fields] id_u3name_u2

      1

      1TEST1
      12TEST2
      13TEST3
      14TEST4


      What I realle need to load in the application for each unique [__KEY_fields] is only the couple ( [id_u3] , [name_u2]) where [id_u3] is the smallest value.

       

      I tried to create a new table in the load script as follow; but it is in error and impossible to launch data load:

       

      [versions1]:

      LOAD

      FirstSortedValue(id_u3, -Aggr(id_u3, name_u2,[__FK_versions])) as [id_u3],

      FirstSortedValue(id_u3, -Aggr(id_u3, name_u2,[__FK_versions])) as [name_u2],

      [__FK_versions] AS [__KEY_fields]

      RESIDENT [version];

       

      Any ideas ?

       

      Thanks for your help.