I have a stored procedure that has this select statement in it:
select
(select Count(FaqId) from faq_read_stats where faqid = Faq.Id) as ReadCount,
Faq.*
from Faq
where Faq.Show = 1 and Faq.Active = 1
This gives me the results I want but it seems like having the ad-hoc select count in there might not be optimized for SQL Server.
I tried doing an inner join on the faq_read_stats table but this did not yield correct results (it left out faq records that did not have a record in faq_read_stats whereas the sql I typed above correctly shows a count of 0 for those).
Is there a more efficient way of getting this data?