Subject Calculating max N-consecutive-days activity
Author Rick Debay
Given activity over a period of days, I'd like to determine the maximum
activity over a given number of consecutive days.
The following SQL gives the maximum over one day, but I can't think how
to do it over more than one.
Well, I can but it's ugly and involves repeating the select statement,
adding a 'skip' for each additional day. And then that wouldn't give
consecutive days.

Select
t.attribute1, t.attribute2
(select first 1 sum(t.quantity)
from tbl_transactions t2
where t2.attribute1=t.attribute 1 and t2.attribute2=t.attribute2
and t2.posted between min(t.posted) And max(t.posted)
group by t2.posted
order by sum(t.quantity) desc
)
From
tbl_transactions t
Where
t.posted between ? And ?
Group by
t.attribute1, t.attribute2

The problem I'm trying to solve, is determining appropriate safety
stock.

Disclaimer: This message (including attachments) is confidential and may be privileged. If you have received it by mistake please notify the sender by return e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change. RxStrategies, Inc. shall not be liable for the improper or incomplete transmission of the information contained in this communication or for any delay in its receipt or damage to your system. RxStrategies, Inc. does not guarantee that the integrity of this communication has been maintained nor that this communication is free from viruses, interceptions or interference.