+ Reply to Thread
Results 1 to 5 of 5

Thread: Using SubQuery to Count 0 Sales Stores

  1. #1
    Forum Contributor
    Join Date
    08-30-2007
    Location
    Vancouver, B.C.
    Posts
    110

    Using SubQuery to Count 0 Sales Stores

    I am trying to learn subquery can can't wrap my head around this one and hoping someone can show me.

    Say table [tbl_Info] has these fields:
    1. Week
    2. Item
    3. Store Number
    4. Sales

    How should I write a subquery to count the number of stores the have 0 sales for each particular item?

  2. #2
    Forum Contributor
    Join Date
    08-30-2007
    Location
    Vancouver, B.C.
    Posts
    110

    Re: Using SubQuery to Count 0 Sales Stores

    33 views but no one knows the answer?

  3. #3
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,161

    Re: Using SubQuery to Count 0 Sales Stores

    Your request is a little vague. Are you interested in zero sales for an item in any week? Or are you trying to determine if a store has never had a sale of a particular item. What do you want your end result to show? Perhaps a little more information might get you a response.

    Alan

  4. #4
    Forum Contributor
    Join Date
    08-30-2007
    Location
    Vancouver, B.C.
    Posts
    110

    Re: Using SubQuery to Count 0 Sales Stores

    Alan, good call.

    The end result I am looking for is:

    Group by:
    Week, Item

    So, essentially, I want to see how many stores have 0 sales within each week for each item.

  5. #5
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,161

    Re: Using SubQuery to Count 0 Sales Stores

    Take a look at this for a starter.

    http://www.databasedev.co.uk/sql-subqueries.html

    Alan

+ Reply to Thread

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