我需要在不使用 #Temp 表或表变量的情况下执行以下操作。不能使用 GROUP BY 进行 CTE。有没有办法做到这一点?
select Title, count(*) as PlayCount
into #Temp
from LC l
join Play p on p.lcID = l.lcID
group by Title
declare @Max int
select @Max = max(PlayCount) from #Temp
select Title, PlayCount, cast(PlayCount as float) / cast(@Max as float) as Weight
from #Temp