SELECT *, 100 * dwindle / total `percentage` FROM ( SELECT u.name buyer, SUM(w.saleTotal) total, SUM( w.saleExternalWaste + w.saleFaultWaste + w.saleContainerWaste + w.saleBreakWaste + w.saleOtherWaste ) dwindle FROM bs.waste w JOIN account.user u ON u.id = w.buyerFk JOIN vn.itemType it ON it.id = w.itemTypeFk WHERE w.year = YEAR(util.VN_CURDATE() - INTERVAL 1 WEEK) AND w.week = WEEK(util.VN_CURDATE() - INTERVAL 1 WEEK, 4) GROUP BY buyerFk ) sub ORDER BY `percentage` DESC;