Si sa faca automat count la ‘loc’ sa nu trebuiasca sa fac eu assign echipei.
Daca ajuta cu ceva acesta este si codul pentru select.
SELECT
pbh.*,
pbt.*,
SUM(pbh.matches) AS matches_sum,
SUM(pbh.kills) AS kills_sum,
SUM(pbh.damage) AS damage_sum,
SUM(pbh.rating) AS rating_sum,
ROUND(AVG(pbh.matches), 0) as matches_avg,
ROUND(AVG(pbh.kills)) as kills_avg,
ROUND(AVG(pbh.damage)) as damage_avg,
ROUND(AVG(pbh.rating), 1) as rating_avg
FROM
pbmr_gamehistory as pbh,
pbmr_teams as pbt
WHERE
pbh.teamid = pbt.teamid
GROUP BY pbh.teamid
SELECT
pbh.*,
pbt.*,
SUM(pbh.matches) AS matches_sum,
SUM(pbh.kills) AS kills_sum,
SUM(pbh.damage) AS damage_sum,
SUM(pbh.rating) AS rating_sum,
ROUND(AVG(pbh.matches), 0) as matches_avg,
ROUND(AVG(pbh.kills)) as kills_avg,
ROUND(AVG(pbh.damage)) as damage_avg,
ROUND(AVG(pbh.rating), 1) as rating_avg
FROM
pbmr_gamehistory as pbh,
pbmr_teams as pbt
WHERE
pbh.teamid = pbt.teamid
GROUP BY pbh.teamid
ORDER BY rating_avg DESC
Functioneaza, il pune pe cel cu rating cel mai mare primul, dar indiferent nu-mi pot da seama cum la loc sa puna 1. pentru primul 2. pentru al doi-lea etc…
.