以下是查询:
select FC.Title, COUNT(FSC.ID) as FCCount, COUNT(FP.NoOfSub), MAX(FP.LastPost)
from ForumCategories FC
left join ForumSubCategories FSC on FSC.CategoryID_FK = FC.ID
left join (select SubCategoryID_FK, Count(ID) NoOfSub, MAX(DatePosted) LastPost
from ForumPosts group by SubCategoryID_FK) FP
on FP.SubCategoryID_FK = FSC.ID
group by FC.Title
order by FC.Title
答案 0 :(得分:0)
您可以使用LINQPad,它支持ADO.NET ENtity框架:http://www.linqpad.net/
在QUERY中输入,并且有一个SQL选项卡,即SQL转换。