首页 > 数据库技术 > 详细

MySQL 某列数据所占总和百分比 SQL实例

时间:2021-05-15 12:21:42      阅读:15      评论:0      收藏:0      [点我收藏+]

SELECT a.address,
a.cont AS countAddress,
b.sum AS sumAddress,
CONCAT( ROUND( a.cont / b.sum * 100, 2 ), ‘‘, ‘%‘ ) AS percent
FROM
( SELECT address, COUNT( address ) AS cont FROM person_base_info GROUP BY address ) a,
(SELECT COUNT(*) AS sum FROM person_base_info ) b

MySQL 某列数据所占总和百分比 SQL实例

原文:https://www.cnblogs.com/magichu/p/14770788.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!