Query display info even if no $

S

STK

I am working with store sales data. Not every store sells every product.
How can I get a query to list all stores and put a zero in a product field if
there are no sales, rather then only listing the stores that sell all the
items?
 
R

Rick B

Use the "product table as your main table in the query and don't put any
criteria under the sales data. Also include your "store" table. Make sure
your join pulls all from both tables.

Without knowing more about your structure it would be hard to give you a
more detailed answer.
 
D

Douglas J Steele

You need to create a LEFT JOIN between Stores and the sales data.

In the graphical query builder, select the line that joins the two tables,
right click on it and choose the option that selects everything from the
Stores table, regardless of whether there's a match in the sales data.

When you do that, you'll end up with a row that has a Null value for those
stores that don't have any sales. Use the Nz function to convert the Null to
a zero.
 
Top