@ypercubeᵀᴹ I'm a bit bind, why first query returns 2 times 101,Delivered and 102,Pending? http://dbfiddle.uk/?rdbms=sqlserver_2014&fiddle=d7979923b310509e81c0df5d654a7680
I have two tables tbl_Generate and tbl_Status.
tbl_Generate has two columns one is TGenerate(having only boolean value 1 or 0) and and Emp_Id
Table is something like this:-
T_ID Tgenerate Emp_ID
1 0 101
2 1 101
3 1 101
4 0 102
5 1 102
...