Optimizing Performance

1

Please login or register to vote for this query.

(click on this box to dismiss)

Code Review

Q&A for peer programmer code reviews

with tagged as (
    select PostId,
           case when TagId = 5 then 1 else null end as Opt,
           case when TagId = 241 then 1 else null end as Perf
    from PostTags
), perfopt as (
    select PostId,
        Max(Opt) as Opt,
        Max(Perf) as Perf
           
    from tagged
    where Perf = 1 OR Opt = 1
    group by PostId
)

Select Count (Opt) as Opt,
       Count(Perf) as Perf,
       Count(case when Opt = 1 and Perf = 1 then 1 else null end) as Both
from perfopt

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results