September 14, 2012 at 10:22 am
Now, I'm confused.
Do you need active items in a particular month?
or active and not sold items in a particular month?
September 14, 2012 at 11:08 am
Sorry guys, I don't know what else to explain 🙁
active items for that month
September 14, 2012 at 11:52 am
This should help you.
--Parameters
DECLARE @Year int, @Month int
SELECT @Year = 2011, @Month = 11
DECLARE @Date date
SET @Date = DATEADD( mm, @Month - 1, DATEADD( yyyy, @Year - 1, 0))
SELECT itemno FROM tbItems
WHERE (SOLDDATE >= @Date OR SOLDDATE IS NULL)
AND PURCHASEDATE < DATEADD( mm, 1, @Date)
With your sample data it gives as a result:
itemno
-------
1000
1003
1004
1005
Viewing 3 posts - 16 through 17 (of 17 total)
You must be logged in to reply to this topic. Login to reply