select distinct t.StoreUnique, t1.trainerCount,t2.subjectCount,t3.DDCount from T_DiveStore t left join ( select count(dt.TrainerID) as trainerCount, t.StoreUnique from T_DiveStore t left join T_DiveStoreOfTrainers dt on t.StoreUnique=dt.StoreUnique group by t.StoreUnique,dt.TrainerID ) t1 on t1.StoreUnique=t.StoreUnique left join ( select count(t.SubjectDtlUnique) as subjectCount, sl.StoreUnique from T_DiveStore sl left join T_SubjectDtl t on t.StoreUnique=sl.StoreUnique group by sl.StoreUnique,t.SubjectDtlUnique ) t2 on t.StoreUnique=t2.StoreUnique left join ( select t.StoreUnique,count(so.OrderUnique) as DDCount from T_DiveStore t left join T_SubjectOrder so on t.StoreUnique=so.StoreUnique group by t.StoreUnique ) t3 on t3.StoreUnique=t.StoreUnique
描述:
1、需要统计店铺下面的员工数
2、需要统计店铺下面的商品数
3、需要统计店铺下面的订单数
方法很粗糙,但不失为一种解决办法!如果还有其它的方式,还请大牛赐教!只为共同学习。
时间: 2024-10-12 12:26:00