TRY THIS Declare @rowcount int select @rowcount = (Select count(*) from tableA A left join tableB B on B.bID = A.bID Left join tableC C on C.clientID = B.clientID where aID= 100) if @rowcount > 1 begin Select C.name as Client , B.Detail as Detail from tableA A left join tableB B on B.bID = A.bID Left join tableC C on C.clientID = B.clientID where aID= 100 else Select C.name as Client from tableA A Left join tableC C on C.clientID = A.bID where aID= 100 end Hope this will help :)
H
hearthofmine
@hearthofmine