3 consecutive days in sql or pl/sql - Oracle 10g
Hi,
I'd sum in sql or pl / sql tonnage of 3 consecutive days from the date of travel for each segment. as you can see in my example (Segment 3743) There may be holes in the date of travel, but the objective is not to exceed 3 calendar days. 0 must be considered tonnage for the day that does not exist in 3 days.
input data:
CODE_SEG - DATE_CIRC - Tonnage
3743 - 01/09/2012 - 114
3743 - 01/09/2012 - 114
3743 - 02/09/2012 - 114
3743 - 02/09/2012 - 114
3743 - 04/09/2012 - 114
3743 - 04/09/2012 - 114
3743 - 05/09/2012 - 57
3743 - 05/09/2012 - 57
3743 - 06/09/2012 - 114
3743 - 06/09/2012 - 114
3744 - 01/09/2012 - 100
3744 - 02/09/2012 - 50
3744 - 03/09/2012 - 20
output data:
CODE_SEG - DATE_CIRC_deb - DATE_CIRC_fin - Tonnage
3743 - 01/09/2012 - 02/09/2012 - 456
3743 - 02/09/2012 - 04/09/2012 - 456
3743 - 04/09/2012 - 06/09/2012 - 570
3744 - 01/09/2012 - 03/09/2012 - 170
Thank you in advance for your help.