Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

3 consecutive days in sql or pl/sql - Oracle 10g

user7375700Feb 4 2013 — edited Feb 4 2013
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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 4 2013
Added on Feb 4 2013
3 comments
656 views