If you can give the complete query, may be a better approach can be given.
select A.*,(select count (*) from (select Deptname FROM @85_Main UNION SELECT Deptname FROM CTE_85) B) as 'Deptcount' from
(SELECT * FROM @85_Main
UNION
SELECT * FROM CTE_85)A
select * From
(SELECT * FROM @85_Main
UNION
SELECT * FROM CTE_85)A
Or you can add one more CTE level to get the Deptcount
Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.
No comments:
Post a Comment