sabeer.mvit (1/16/2013)
The ccount is not obtain directly from table as done here.Am rather using the View written as belowWith compTable(cid,ccid,ccount)
as
AS
(
select parentid,childrenId,COUNT(cmpcd) FROM
group by parentid,childrenId,cmpcd
)
select decsr,
pnumber,
(SELECT count(ccount) FROM compTable where parentid=ch.cn_id) as [Count] ,--[this is ccount]
-- here i need the total count
from table ch inner join table b
on ch.id=b.id
Can you post the whole query referencing the view, and also the view definition, please? Some sample data would help too - exactly what will probably depend upon the view definition.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden