how to select active inventory

  • Now, I'm confused.

    Do you need active items in a particular month?

    or active and not sold items in a particular month?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Sorry guys, I don't know what else to explain 🙁

    active items for that month

  • 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

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 3 posts - 16 through 17 (of 17 total)

You must be logged in to reply to this topic. Login to reply