Buen dia Comunidad.
Good morning Community.
I am having doubts about how to obtain the POSITION CHART of the following SCORE table in MYSQL.
1: This is my table where the user records the escort of each sport played.
2: Now this is where I have doubts, how do I get the POSITION CHART according to the attached model where the following is calculated: PJ = Matches played PG = Matches Won PP = Lost Matches PE = Draws Matched GF = Goals For GC = Goals Against DFG = Total Goal Difference = where the winning team obtains 3 Points.
I wait for your kind support
I could only make the amount of encounter that 1 team has made
select category, report, gender, Team1, count (*) from score where Team1 = 'red' and category = 'CAT 3'
Best Answer
Looking the task and sample data and ignoring sample output...
For MySQL 8+ :
... and for MySQL 5+ :
If you need the data for all
categoria
and/orndeporte
then add them to output fields list and GROUP BY clause, and remove from WHERE clause (or edit if you need the result for some values only).fiddle