kamal213 Posted August 9, 2012 Share Posted August 9, 2012 Hi guys, Please could you tell me how you would calculate the sum of a column..but of each distinct value in a a table? So for example if the distinct values of a salesman in your table are: John, Bill and Bob how would you calculate there total sales without manually typing "count where salesman =John" etc Please let me know if you need more information. Thanks Link to comment https://forums.phpfreaks.com/topic/266853-countsum-of-each-distinct-value/ Share on other sites More sharing options...
Barand Posted August 9, 2012 Share Posted August 9, 2012 SELECT salesman, SUM(sales) as total FROM tablename GROUP BY salesman Link to comment https://forums.phpfreaks.com/topic/266853-countsum-of-each-distinct-value/#findComment-1368070 Share on other sites More sharing options...
kamal213 Posted August 9, 2012 Author Share Posted August 9, 2012 Your right!! tried it already and it works!!! Perfect! Thanks for your help Link to comment https://forums.phpfreaks.com/topic/266853-countsum-of-each-distinct-value/#findComment-1368078 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.