This should do itcreate table #customer (ID int NOT NULL ,VS int NOT NULL )create table #Customerview (ID int NOT NULL ,Tname nchar (10) NOT NULL ,FN nchar (3) NOT NULL,PV int NOT NULL,status nchar (2))insert #Customer select 1, 2 union allselect 2, 1insert #Customerviewselect 1, 'PERSONAL','VT',3,'Y' union allselect 2, 'PERSONAL','VT',4,'Z' update #Customerviewset PV = #Customer.VSfrom #Customerviewinner join #Customer on #Customerview.ID = #Customer.IDwhere #Customerview.PV <> #Customer.VS and #Customerview.status = 'Y'Select * from #Customerview