4 Replies Latest reply: Jan 13, 2015 11:22 PM by danny rock RSS

    Script to load the first sorted instance of a record

    danny rock

      Hi guys,

      I am trying to figure out a way to load the first instance of duplicated data in my script. I will then use this data to join to another set of data.

       

      e.g,

      CustomerCummulative SumDate
      a5028/12/14
      a4020/12/14
      a3017/12/14
      a2015/12/14
      a1001/12/14

       

      So I want only one instance of customer a which would be the latest sorted date where sum would equal to 50 and data would be 28/12/14.

       

      I think in Teradata, I would have the following at the end of my SQL

      qualify rownumber() over( partition by customer, cummulative order by date)=1