Rid dept ID 1 1 1 2 6 2 3 2 3 4 3 4 5 1 1 6 2 2 7 3 3 8 4 4 9 1 1 10 2 2 11 3 3 12 7 4 Hi All, I have a scenario where the following two lines in a table, if the value in the Dept column is anything except the distinct values from column Id, it should be showing the values in result. For example, if the id selected is 1 it should check if the corresponding values in Dept column is anything except(1,2,3,4), if yes list that and same goes for all the values in column Id. In case of Id=2, the visible row should be Dept 6 ID 2 as Dept code is not from distinct values from ID.
select DO1.dept,DO2.ID ,* from Table1 DO1 left join Table2 DO2 on DO1.Rid=DO2.Rid where DO1.dept<>DO2.ID
select mt.dept, mt.id from mytable mt where mt.dept not in (select distinct mt2.id from mytable mt2)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)