仅是我对您要求的http://sqlfiddle.com/#!9/e9206/16的猜测
因为它带来了预期的结果:
SELECt A.family, C.NbrFamily,A.sub_family,B.NbrSubFamily,A.name,COUNT(A.Name) FROM commodities as ALEFT JOIN ( SELECt family,sub_family,COUNT(Name) AS NbrSubFamily FROM commodities GROUP BY family,sub_family) BON A.sub_family = B.sub_family AND A.family = B.family LEFT JOIN ( SELECt family,COUNT(Name) AS NbrFamily FROM commodities GROUP BY family) CON A.family = C.family GROUP BY A.family,A.sub_family,A.nameORDER BY A.id
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)