Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
hi everybody,
I have following table:
| OrderId | OrderDate | SessionDate | OrderSessionDate-Diff |
|---|---|---|---|
| AA | 2011-07-15 12:07:00 | 2011-07-15 12:00:00 | 00:07 |
| BB | 2011-11-06 21:12:00 | 2011-11-06 21:00:00 | 00:12 |
| BB | 2011-11-06 21:12:00 | 2011-11-06 21:06:00 | 00:06 |
| BB | 2011-11-06 21:12:00 | 2011-11-06 21:20:00 | -00:08 |
| CC | 2011-03-18 23:04:00 | 2011-03-18 23:00:00 | 00:04 |
| CC | 2011-03-18 23:04:00 | 2011-03-18 23:10:00 | -00:06 |
| DD | 2011-02-08 14:08:00 | 2011-02-08 14:07:00 | 00: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:
| OrderId | OrderDate | SessionDate | OrderSessionDate-Diff | Flag |
|---|---|---|---|---|
| AA | 2011-07-15 12:07:00 | 2011-07-15 12:00:00 | 00:07 | Yes |
| BB | 2011-11-06 21:12:00 | 2011-11-06 21:00:00 | 00:12 | No |
| BB | 2011-11-06 21:12:00 | 2011-11-06 21:06:00 | 00:06 | Yes |
| BB | 2011-11-06 21:12:00 | 2011-11-06 21:20:00 | -00:08 | No |
| CC | 2011-03-18 23:04:00 | 2011-03-18 23:00:00 | 00:04 | Yes |
| CC | 2011-03-18 23:04:00 | 2011-03-18 23:10:00 | -00:06 | No |
| DD | 2011-02-08 14:08:00 | 2011-02-08 14:07:00 | 00:01 | Yes |
Please help, THX!
Hi,
See the attached qvw/
Hope it help.