1
我的CTE如下(邏輯移除)噸-SQL COUNT返回值
;with cte_a as
(
select ID, Count(AnotherID) as Counter
from Table_A
group by ID
)
和用戶定義的函數,它接受一個Id作爲輸入,並返回一個表。
udf_GetRelatedItemIds(@Id)
我想只計算從cte_a中每個ID的用戶定義函數返回的相關項目id的數量。
我試圖像下面,但它沒有工作
;with cte_a as
(
select ID, Count(AnotherID) as Counter
from Table_A
group by ID
)
select
ID,
Count(select RelatedId from udf_GetRelatedItemIds(ID))
from cte_a
請提出一個解決方案。
對我來說不是那麼無聊:)謝謝Tahbaza! – stackoverflowuser 2010-07-08 18:32:36