+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    06-04-2007
    Posts
    57

    Query for products ordered by month(s) and ytd

    I am looking to create a single query for the following:

    I would like to capture a list of all products and their descriptions with ytd total, previous month, current month, and projected for next month.


    All information is held in the same view as follows:
    Product
    ProductDescription
    DisburseDate

  2. #2
    Valued Forum Contributor
    Join Date
    04-23-2009
    Location
    IOWA
    MS-Off Ver
    2010 Professional
    Posts
    233

    Re: Query for products ordered by month(s) and ytd

    This is how I would do it.

    SQL Code:

    Code:
    SELECT ProductData.Product, ProductData.ProductDescription, Sum(IIf([ProductData]![DisburseDate]<=Date() And Year([ProductData]![DisburseDate])>=Year(Date()),[Qty],0)) AS YTD, Sum(IIf(Month([ProductData]![DisburseDate])=Month(Date()),[Qty],0)) AS [Current Month], Sum(IIf(Month([ProductData]![DisburseDate])=(Month(Date())+1),[Qty],0)) AS [Predicted Next Month]
    FROM ProductData
    GROUP BY ProductData.Product, ProductData.ProductDescription;
    You said you wanted totals, I assumed you had to have a Qty field.

    Hope this helps,

    Dan
    "I am not a rocket scientist, I am a nuclear engineer." - Split_atom18
    If my advice has been helpful to you, then please help me by clicking on the scales and adding to my reputation, Thanks!

  3. #3
    Registered User
    Join Date
    06-04-2007
    Posts
    57

    Re: Query for products ordered by month(s) and ytd

    I do not have a quantity field, all entries are listed seperately on a per order basis.

  4. #4
    Valued Forum Contributor
    Join Date
    04-23-2009
    Location
    IOWA
    MS-Off Ver
    2010 Professional
    Posts
    233

    Re: Query for products ordered by month(s) and ytd

    K so remove [Qty] and place a 1 in there.
    "I am not a rocket scientist, I am a nuclear engineer." - Split_atom18
    If my advice has been helpful to you, then please help me by clicking on the scales and adding to my reputation, Thanks!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0