sql - TSQL find missing Values for repeating records -
sample data: pageid attribute 2860 category 2860 sub-category 2861 tag 2861 tag 2862 tag 2862 category 2863 sub-category 2883 category 2883 sub-category problem # 1: need find page ids attribute sub-category not exists result should : 2861 2862 problem # 2: need find page ids attribute sub-category , attribute category both not exists result should : 2861 1) select pageid thetable pageid not in (select pageid thetable attribute = 'sub-category') 2) select pageid thetable pageid not in (select pageid thetable attribute = 'sub-category') , pageid not in (select pageid thetable attribute = 'category')