mysql - getting individual records from a group by -


i have 2 tables, 1 table of names category tag , other table of scores each name

id    name      category 1     dave      1 2     john      1 3     lisa      2 4     jim       2 

and score table is

personid      score 1             50 2             100 3             75 4             50 4             75 

i query returned like

category    totalscore    names 1           150           dave, john 2           200           lisa, jim 

is possible 1 query?

i can totals sum query , grouping category cannot see way names like.

many thanks

you need use group_concat:

select category, sum(score) totalscore, group_concat(name) names categories join scores on scores.category = categories.category group category 

or better:

group_concat(distinct name order name asc separator ',') names 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -