你好我有两个这样的查询
select COUNT(*)as Num_Occ, trial
into ##temp_occ
from [E1].[dbo].[EVENT_SIM]
where MODELING_ID=1
group by trial,MODELING_ID
order by TRIAL
select Num_Occ, count(*)as Num_Trials
from ##temp_occ
group by Num_Occ ORDER BY Num_Occ
我不希望一直创建临时表来执行此操作,因此我使用子查询将两者结合起来。但是,我的代码返回错误,指出无效名称 Num_Occ。
select Num_Occ, count(*)as Num_Trials
from [E1].[dbo].[EVENT_SIM]
where NUM_Occ in (select COUNT(*)as Num_Occ
from [E1].[dbo].[EVENT_SIM]
where MODELING_ID=1)
你能帮我理解我应该在哪里改变吗?非常感谢你!