Jump to content

need help with a query, and eventually a stored procedure


ckanoab

Recommended Posts

I've hit a mental block and just can't figure out how to get the results i want.

 

I have 3 tables, INVENTORY,ORGANIZATION,CATEGORIES

 

INVENTORY and CATEGORIES should be self explanatory, INVENTORY has a key field sku, CATEGORIES key field is ID.

 

the organization ties these 2 tables together... it contains 2 fields: sku,category

sku matching one of the sku's in the INVENTORY table and category matching an ID in the CATEGORIES table.

 

what i'm looking for is a query that will list every category and the number of products assigned to that category that are in stock, i have a query that does that for the most part, but it only shows categories that have 1 or more products in stock, never an empty category

 

 

the sql for that is

 

select category,count(organization.sku) as InStockSKUCount from Organization left join INVENTORY on organization.sku=inventory.sku where inventory.store_quantity>0 group by category

 

 

how i get the results to reflect the empty categories as well?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.