mysql - How to count values from column whilst taking into account a qty column -


i've seen other questions never column used

say i've got table

name  |   qty nup       1 foo       1 foo       3 tup       2 foo       1 nup       4 

in example ge result like

name  |  qty foo      5 tup      2  nup      5 

at moment have done not take account qty

$sql = "select  `name`,count(*) count orders group `name` order count desc"; 

try this

$sql = "select name, sum(qty) qty orders group name order qty desc"; 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo