gardan06 Posted March 11, 2008 Share Posted March 11, 2008 I want my table to view percentages. Here's how: Name Qty Pct Qty John 10 10% ... Kerry 2 2% __________________________________ 100 100% I want "Pct Qty" to automatically compute the percent of the "Qty" by the formula (qty/total qty)*100. is it possible ? thanks. Quote Link to comment https://forums.phpfreaks.com/topic/95566-total-of-columns/ Share on other sites More sharing options...
Barand Posted March 11, 2008 Share Posted March 11, 2008 SELECT a.name, a.qty, a.qty*100/x.tot as pc FROM tablename a JOIN (select SUM(qty) as tot from tablename) as x Quote Link to comment https://forums.phpfreaks.com/topic/95566-total-of-columns/#findComment-489373 Share on other sites More sharing options...
gardan06 Posted March 12, 2008 Author Share Posted March 12, 2008 SELECT a.name, a.qty, a.qty*100/x.tot as pc FROM tablename a JOIN (select SUM(qty) as tot from tablename) as x amazing! thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/95566-total-of-columns/#findComment-490173 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.