SELECT *, 100 * dwindle / total `percentage` FROM ( SELECT u.name buyer, SUM(saleTotal) total, SUM(w.saleInternalWaste + w.saleExternalWaste) 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;