基础问题,关于嵌套查询的
就是订单,用户表,两个表join查根据userid分组统计的订单数
select user.userid,count(opportunityID) as 订单总数 from UserTable as [user]
join Business_Opportunitys as opportunity
on user.userid = opportunity.userid
group by user.userid
select username,count(opportunityID) from UserTable where userid in(
select user.userid,count(opportunityID) as 订单总数 from UserTable as [user]
join Business_Opportunitys as opportunity
on user.userid = opportunity.userid
group by user.userid
)