sql - How to list fields that are missing a trait and eliminate the ones that are not -


first, i'm using sql server management studio.

i've tried searching finding right wording what's failing me.

i'm trying develop query sql class returns list of businesses resellername have not sold 1 of 4 types of productsproductcategorykey.

like listing recipes not include carrots.

it requires me join 5 tables able link resellername productcategory.

current code looks this:

select distinct      r.resellername        (((dimreseller r        full outer join factresellersales rs on r.resellerkey = rs.resellerkey)      inner join dimproduct p on rs.productkey = p.productkey)     inner join dimproductsubcategory psc on  p.productsubcategorykey = psc.productsubcategorykey) inner join dimproductcategory pc on psc.productcategorykey = pc.productcategorykey order r.resellername` 

i'm lost where clause should include list each company has not sold bike. thought try , make category 1 field null field or something.

any appreciated.

the easiest way rewrite use left join find matches on productcategorykey, , is null remove rows include match, like;

select distinct r.resellername dimreseller r left join factresellersales rs   on r.resellerkey = rs.resellerkey) left join dimproduct p   on rs.productkey = p.productkey) left join dimproductsubcategory psc   on  p.productsubcategorykey = psc.productsubcategorykey) left join dimproductcategory pc   on  psc.productcategorykey = pc.productcategorykey  , pc.productcategorykey in (1,2,3,4,5,6,7,8) pc.productcategorykey null order r.resellername 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -