#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