Query to select not Null records in SQL Server

Last Reply 11 days ago By dharmendr

Posted 11 days ago

Dear All,

I have the query mentioned below.

SELECT [BNK_OrgNum],[BNK_RecRef],[MsgTp_RecRef],[MsgTyp_MsgID],[MsgTyp_Desc],MsgTyp_FK_ServType,MsgTp_Active 
FROM [Bank_Master],[SysDef_MessageType],[Bank_MsgType]
WHERE [MsgTp_FK_MsgType]=[MsgTyp_RecRef] AND [MsgTp_FK_Bank]=[BNK_RecRef] 
--AND [MsgTp_Active]=0 

For Some BNK_OrgNum the MsgTp_Active column=1 ,some MsgTp_Active=0. I need a query where the MsgTp_Active=0 where the BNK_OrgNum  is not using any MsgTyp_MsgID

Posted 11 days ago

Check below query.

SELECT [BNK_OrgNum],[BNK_RecRef],[MsgTp_RecRef],[MsgTyp_MsgID],[MsgTyp_Desc],MsgTyp_FK_ServType,MsgTp_Active 
FROM [Bank_Master],[SysDef_MessageType],[Bank_MsgType]
WHERE [MsgTp_FK_MsgType]=[MsgTyp_RecRef] AND [MsgTp_FK_Bank]=[BNK_RecRef] 
AND ([MsgTp_Active]=0 AND BNK_OrgNum IS NULL)