8 Replies Latest reply: Apr 18, 2013 10:59 AM by Marius Koekemoer RSS

    How to select the first date

    Marius Koekemoer

      Hi guys,

       

      I have a set of data that consists of the following fields:

       

      ID_Number;

      OrderDate; and

      Flag.

       

      The data represents something that looks like this:

       

      ID_Number                       OrderDate                          Flag

      8304125002087               03/06/2011                         0

      8304125002087               07/07/2012                         1

      8304125002087               03/06/2013                         1

      8212285002087               03/07/2011                         0

      8212285002087               17/06/2012                         0

      8212285002087               04/05/2013                         1

      7601285002087               06/06/2011                         1

      7601285002087               06/08/2012                         0

       

      What I need to achieve out of this is to be able to identify (in the script) the first OrderDate where Flag = 1 and Populate a new field with this date.

      For instance in this example I need the following populated:

       

      ID_Number                      OrderDate                           Flag                    NewDate

      8304125002087               03/06/2011                         0                         07/07/2012

      8304125002087               07/07/2012                         1                         07/07/2012

      8304125002087               03/06/2013                         1                         07/07/2012

      8212285002087               03/07/2011                         0                         04/05/2013

      8212285002087               17/06/2012                         0                         04/05/2013

      8212285002087               04/05/2013                         1                         04/05/2013

      7601285002087               06/06/2011                         1                         06/06/2011

      7601285002087               06/08/2012                         0                         06/06/2011

       

      How would I go about doing this?

       

      Your assistance will be highly appreciated.

       

      Kindly thanking you,

      Marius