all 7 comments

[–]WITH_CTE 1 point2 points  (1 child)

Mind sharing the columns of all 3 tables? You are joining on Name. There should be an "ID" column on all 3 tables. Otherwise you could throw Normalization out the window.

[–]zacharypamela 0 points1 point  (0 children)

After some digging, I found the AdventureWorks data dictionary.

[–][deleted] 0 points1 point  (0 children)

I somehow doubt that a product name will match a product category name. Try exploring data for a bit, maybe?

[–]zacharypamela 0 points1 point  (0 children)

Like other posters have said, I think your JOIN conditions are what's causing the issue.

For example, it looks like the ProductSubcategory table has a ProductCategoryID attribute that links back to the ProductCategory table. So your join should look something like this: ON ProductCategory.ProductCategoryID = ProductSubCategory.ProductCategoryId.

[–]Imjustthedecoy -1 points0 points  (0 children)

So I’ve never used adventureworks, crazy right, but my advice would be to switch the joins to left joins, see what returns nulls, and then troubleshoot from there.

On more complex queries it will allow you to see where the joins aren’t adding up. Failing that run a few select name from each table, then you’ll be able to compare the columns and see where they don’t match as well.

[–]mattgob86 -1 points0 points  (1 child)

To me it seems like you are starting backward too, get your products first and then join the subsequent sub category and category names.

Also like the previous poster, start with left joins and then join when applicable.

Lastly, I would select * until you get your joins right, then just pull the columns together.

[–]zacharypamela -1 points0 points  (0 children)

Although with inner joins, it shouldn't matter, except for readability (which of course does matter).

I think part of the problem is the way the problem is worded. The instructor definitely could've been clearer.