I work on sql server 2012 . if face issue I can't get parts that not have all features on table settings
so I will count distinct features from table settings and compare it with count features per part
if count features per part on table part feature <>count distinct features on table settings by PLID and code type
then display it .
as example part 9010 have only one feature 15000160 from table settings and not have feature 15000171
then display it .
as example part 9041 have only one feature 15000171 from table settings and not have feature 15000160
then display it .
part id 7731 have two features 15000171,15000160 as part settings have two features then no need
to display it because it have full features
so How to write query do that
create table #settings
(
SettingId int,
PLID INT,
CodeType int,
Code nvarchar(50),
featureKey int
)
insert into #settings
values
(1,2890,798541,'Ear99',NULL),
(1,2890,798541,'Ear70',15000160),
(1,2890,798541,'Ear99',15000171),
(1,2890,798541,'e900841',15000160)
create table #partFeature
(
PartId int,
FeatureKey int
)
insert into #partFeature
values
(9010,15000160),
(7070,15000171) ,
(9041,15000171) ,
(2030,15000160) ,
(5871,15000160) ,
(5871,15000171) ,
(7731,15000160) ,
(7731,15000171)
result I need
PartId FeatureKey
9010 15000160
7070 15000171
9041 15000171
2030 15000160