在单个查询中进行分组,排序和计数

在单个查询中进行分组,排序和计数,第1张

在单个查询中进行分组,排序和计数

仅是我对您要求的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


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5675337.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存