Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Help with dates

Author  Topic 

grovey
Starting Member

3 Posts

Posted - 2005-06-03 : 13:47:05
Hi:

I am working with a table which looks like this:
Item Number
Store Number
POS Quantity
Date

Now, there are many times when the column [POS Quantity] is equal to zero. I would like to find out the {[Item Number], [Store Number]} combination for cases when the [POS Quantity] has been equal to zero for more than 15 consecutive days.

All help will be appreciated.

Thanks

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2005-06-03 : 14:11:14
Your requirements are too vague, there's quite a few ways to interpret what you are saying. How about some sample data that covers all of the possibilities we need to account for, and then what results should be returned based on that?

- Jeff
Go to Top of Page

grovey
Starting Member

3 Posts

Posted - 2005-06-03 : 14:26:45
Some data could be:
123 | 234 | 0 | 2/3/2005
123 | 234 | 0 | 2/4/2005
123 | 234 | 0 | 2/5/2005
.
.
.
125 | 234 | 0 | 2/6/2005
125 | 235 | 1 | 2/6/2005
125 | 236 | 0 | 2/8/2005

So, in this data, the first column is the item number, the second the store number, the third, POS quantity, and the fourth the date this transaction is recorded.

Now, I would like all Item Number, Store Number combinations, where the POS Quantity column has been equal to 0 for 15 consecutive days for the same Item Number, Store Number combination.

If still a problem, let me know.

Thanks

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-06-03 : 14:58:59
Sounds like a streaks and run kinda thing

http://www.sqlteam.com/item.asp?ItemID=12654



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

grovey
Starting Member

3 Posts

Posted - 2005-06-03 : 15:03:32
That's what it is! Thanks very much for the help.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-06-03 : 15:06:00
I'm glad Jeff could be of assistance



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
   

- Advertisement -