1 Reply Latest reply: Mar 23, 2012 5:45 AM by Yigal Ben Oren RSS

    creating flag if value is minimum

      hi everybody,

       

      I have following table:

       

      OrderId
      OrderDateSessionDate
      OrderSessionDate-Diff
      AA2011-07-15 12:07:002011-07-15 12:00:0000:07
      BB2011-11-06 21:12:002011-11-06 21:00:0000:12
      BB2011-11-06 21:12:002011-11-06 21:06:0000:06
      BB2011-11-06 21:12:002011-11-06 21:20:00-00:08
      CC2011-03-18 23:04:002011-03-18 23:00:0000:04
      CC2011-03-18 23:04:002011-03-18 23:10:00-00:06
      DD2011-02-08 14:08:002011-02-08 14:07:0000:01

       

      I need a table with a flag column that identified the row with minimum value of column 'OrderSessionDate-Diff' for each order.

      My result should look like this:

       

       

       

      OrderIdOrderDateSessionDateOrderSessionDate-DiffFlag
      AA2011-07-15 12:07:002011-07-15 12:00:0000:07Yes
      BB2011-11-06 21:12:002011-11-06 21:00:0000:12No
      BB2011-11-06 21:12:002011-11-06 21:06:0000:06Yes
      BB2011-11-06 21:12:002011-11-06 21:20:00-00:08No
      CC2011-03-18 23:04:002011-03-18 23:00:0000:04Yes
      CC2011-03-18 23:04:002011-03-18 23:10:00-00:06No
      DD2011-02-08 14:08:002011-02-08 14:07:0000:01Yes

       

      Please help, THX!