The data below is from an Oracle table. I want to get the right date_req for each group of rcvr. The following is the conditions,
If calc is a decimal number, use the corresponding date_req
If the above condition is false then check calc for "1" and get the maximum date_req
Calc is qty_rec divided by qty_ord. Possible value for calc is 0, 1 and a decimal number.
There can only be one decimal number (if exist) for each group of rcvr.
The last 2 line below is the result we need. Using SQL is the prefer method. Although, we can use Excel solution as a last resort. Appreciate the help.
rcvr date_req qty_ord qty_rec calc
a 1/1/2008 10 10 1
a 2/1/2008 20 5 0.25
a 4/1/2008 25 0 0
a 6/1/2008 30 0 0
b 7/1/2008 5 5 1
b 8/1/2008 10 10 1
b 1/1/2009 15 15 1
b 3/1/2009 20 0 0
b 4/1/2009 25 0 0
b 6/1/2009 30 0 0
b 7/1/2009 35 0 0
b 9/1/2009 40 0 0
Results
a 2/1/2008 20 5 0.25
b 1/1/2009 15 15 1
Try not to use excel, it makes things very massy