CTE w CTE
Czy jest możliwe napisanie CTE w CTE?
Chcę, żeby podążała za tą logiką, ale tłumacz nie lubi tego kodu.
with outertest as(
with test as (
select
SRnum,
gamenumber,
StartOfDistribution,
ApplicationNumber
from #main
where startofdistribution = '2011-06-14 00:00:00.000'
and SRnum = '313'
--order by SRnum, gamenumber, StartOfDistribution, ApplicationNumber
)
select
ApplicationNumber
,count(*) as RetailerAppearance
from test
group by ApplicationNumber
having count(*) = 4
) select count(*) from outertest