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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.