Common Table Expressionを使用できます:
with cte as (
select CONVERT(DECIMAL(10,1),100 - (CAST(COUNT(DISTINCT case when PD.ExceptionCode != ' ' then PD.Id END) as float)/CAST(COUNT(PD.Id) as float)*100)) as Percentage
from Product as P
inner join Item as PD on PD.ProductId = P.ProductId
)
select Percentage from cte where Percentage < 50
subqueryを使用することは可能ですが、私にとっては CTE の方が読みやすいです
select *
from (
select CONVERT(DECIMAL(10,1),100 - (CAST(COUNT(DISTINCT case when PD.ExceptionCode != ' ' then PD.Id END) as float)/CAST(COUNT(PD.Id) as float)*100)) as Percentage
from Product as P
inner join Item as PD on PD.ProductId = P.ProductId
) as A
where A.Percentage < 50
を使用してこれを解決することもできますが、読みやすく保守しにくいでしょう。
select CONVERT(DECIMAL(10,1),100 - (CAST(COUNT(DISTINCT case when PD.ExceptionCode != ' ' then PD.Id END) as float)/CAST(COUNT(PD.Id) as float)*100)) as Percentage
from Product as P
inner join Item as PD on PD.ProductId = P.ProductId
having CONVERT(DECIMAL(10,1),100 - (CAST(COUNT(DISTINCT case when PD.ExceptionCode != ' ' then PD.Id END) as float)/CAST(COUNT(PD.Id) as float)*100)) < 50