im tring to replace
Select y.ID
(select COUNT(y.ID) from x where x.ylID = y.ID)
FROM y
with somthing like this:
Select y.ID
count(case when x.ylID = y.ID then y.ID else null end ) as 'cnt'
FROM y
join x on x.ylID = y.ID
it's working fine with
(case when x.ylID = y.ID then y.ID else null end )
the problem is with the count i receive aggregation error
how can i solve this with minimum performance impact?