S
SpookiePower
I have a table called TReport which have to
columns iTeam1 and iTeam2.
I have 3 teams, 1 2 and 3 where each of them have a name
which I get from the table TTeam.id
I want to count how many times each team are in
iTeam1 and iTeam2 and them sort them by how
many times they are in these two column, with each
teams name.
My first problem is how to count two columns.
I have tried to do it like this -
count(iTeam1+iTeam2) and Sum(iTeam1 +iTeam2)
But it does not work.
This is my SQL -
SELECT Holdnavn, count(iTeam1+iTeam2) AS X
FROM TReport INNER JOIN TTeam ON TReport.iTeam1=TTeam.id
WHERE iTeam1=11 Or iTeam1=12 Or iTeam1=13 iTeam2=11 Or iTeam2=12 Or
iTeam2=13
GROUP BY Holdnavn
ORDER BY count(iTeam1+iTeam2) DESC;
My final result should look like this.
BlueTeam 100
ReadTeam 70
GreenTeam 50
....
....
columns iTeam1 and iTeam2.
I have 3 teams, 1 2 and 3 where each of them have a name
which I get from the table TTeam.id
I want to count how many times each team are in
iTeam1 and iTeam2 and them sort them by how
many times they are in these two column, with each
teams name.
My first problem is how to count two columns.
I have tried to do it like this -
count(iTeam1+iTeam2) and Sum(iTeam1 +iTeam2)
But it does not work.
This is my SQL -
SELECT Holdnavn, count(iTeam1+iTeam2) AS X
FROM TReport INNER JOIN TTeam ON TReport.iTeam1=TTeam.id
WHERE iTeam1=11 Or iTeam1=12 Or iTeam1=13 iTeam2=11 Or iTeam2=12 Or
iTeam2=13
GROUP BY Holdnavn
ORDER BY count(iTeam1+iTeam2) DESC;
My final result should look like this.
BlueTeam 100
ReadTeam 70
GreenTeam 50
....
....