The query is
Select id from TableA
where typ_cd="NT"
and id not in
( select id from TableA where typ_cd="BB")
I need to find those id’s whose type_cd =”NT” and compare those id’s with the same table which are not present for type_cd=”BB” .I pretty confused why the above query is not returning the correct values.
Edit: -I’m referencing the same table and there are no null values for the column ID
Please let me know how can i achieve the same result in sql server so that i can try to write an equivalent query in sybase
TableA
id typ_cd
1 NT
1 BB
3 NT
4 NT
4 BB
I need the id=1 as the result since the id=1 is present for typ_cd=NT but not for typ_cd=BB
But at present with the above query im getting null in sybase
Replace the double quotes with single quotes.