calculate totals between dates?

  • I'm not sure if what I'm looking to is possible, but here goes - I'm wanting to do is calculate activity between sales dates. Suppose I have a table that records car sales and I record 5 this month and I add 60 customers to our customer table this month is it possible cacultate the number of customers added between each sale???

  • Hi there,

    Any chance you could post table structures with some sample data and your expected results?

    Here is a very useful article on how to post this information: http://qa.sqlservercentral.com/articles/Best+Practices/61537/

    ///edited typo

  • You may have Customer_Created_Date in Customer table. And you have Sales_Date in Sales Table.

    You can use

    SELECT COUNT(Customer_ID) FROM Customer

    WHERE Customer_Created_Date BETWEEN Sales_Date_1 AND Sales_Date_2

    For Sales_Date_1 and 2, you can use nested query or view.

  • ekla_pathik (7/15/2009)


    You may have Customer_Created_Date in Customer table. And you have Sales_Date in Sales Table.

    You can use

    SELECT COUNT(Customer_ID) FROM Customer

    WHERE Customer_Created_Date BETWEEN Sales_Date_1 AND Sales_Date_2

    For Sales_Date_1 and 2, you can use nested query or view.

    NO. Absolutely NOT. BETWEEN includes both items.

    dcarpenter... are you all set on this or do you still need some help?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

Viewing 4 posts - 1 through 3 (of 3 total)

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