+ Reply to Thread
Results 1 to 5 of 5

Using SubQuery to Count 0 Sales Stores

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

    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
    149

    Re: Using SubQuery to Count 0 Sales Stores

    33 views but no one knows the answer?

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,860

    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
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

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

    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
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,860

    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.6.0 RC 1