数据库
首页 > 数据库> > MySQL 某列数据所占总和百分比 SQL实例

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

作者:互联网

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

标签:COUNT,info,cont,某列,sum,address,SQL,MySQL,SELECT
来源: https://www.cnblogs.com/magichu/p/14770788.html