Skip to Main Content

Tricky Analytical/Aggregae Sql

dd_ramSep 6 2008 — edited Sep 9 2008
Hi,
I have data like below.
MRP_DATE SHORT_FLAG
8/25/2008 Y
8/26/2008 Y
8/27/2008 N
8/28/2008 Y
8/29/2008 Y
8/30/2008 Y
8/31/2008 N
9/1/2008 Y
9/2/2008 Y
9/3/2008 N
9/4/2008 N
I want to calculate Short_days. If the Short_flag changes from Y to N, it needs to be reset to 1. The output should look like below.
MRP_DATE SHORT_FLAG Shortage_days
8/25/2008 Y 1
8/26/2008 Y 2
8/27/2008 N 0
8/28/2008 Y 1
8/29/2008 Y 2
8/30/2008 Y 3
8/31/2008 N 0
9/1/2008 Y 1
9/2/2008 Y 2
9/3/2008 N 0
9/4/2008 N 0
Would you guys Please tell me how to achieve this??

Thanks,
Ram.
This post has been answered by Solomon Yakobson on Sep 7 2008
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked due to inactivity on Oct 7 2008
Added on Sep 6 2008
29 comments
3,929 views