Results 1 to 2 of 2
  1. #1
    tjstromquist is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2012
    Posts
    2

    Count Function in query

    I have the following fields:

    FiscalYr


    FiscalWk
    SKU
    Store_Nbr
    Qty_Sold

    I want to include a field that shows the count of store numbers with qty_sold > 0 each week. I don't need to see the actual store number so I will remove that from the query.
    I tried multiple ways and cannot get it to work, what am I missing?


    Result set should look like the following:

    FiscalYr FiscalWk SKU StoreCount
    2012 7 315222 1201
    2012 8 31522 1245

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Welcome to the forum!

    I assume that your raw data looks something like this:


    FiscalYr|FiscalWk|SKU|Store_Nbr|Qty_Sold
    2012|1|323943|1|10
    2012|1|323943|2|50
    2012|1|399399|1|22
    2012|2|323943|1|99
    2012|2|399399|2|25


    Your query would need to group by fiscal year, fiscal week and SKU and then sum the Qty_Sold

    SELECT FiscalYR, FiscalWk, SKU, SUM(Qty_Sold) as SumOfQty_Sold
    FROM tablename
    GROUP BY FiscalYr, FiscalWk, SKU

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 0
    Last Post: 04-25-2011, 07:58 PM
  2. count and switch function in same select query
    By sandlucky in forum Queries
    Replies: 2
    Last Post: 04-08-2011, 11:16 PM
  3. Count function on query
    By yousillygoose in forum Queries
    Replies: 1
    Last Post: 02-15-2010, 09:58 PM
  4. Count function in Query always Read Only?
    By terbs in forum Queries
    Replies: 3
    Last Post: 01-19-2010, 05:43 PM
  5. Query using count function
    By wasim_sono in forum Queries
    Replies: 0
    Last Post: 11-28-2007, 03:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums