Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

replace select (select count(*) from x)

$
0
0

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?


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>