Hallo,
habe folgendes Problem: 2 SELECT's aus 1 Tabelle mit 8 teams, xrunden und Punkten
möchte ich in einer Abfrage in ein oberes und unteres Play OFF
teilen. Beide Abfrage funktionieren für sich korrekt. Ich möchte jedoch dies in einer Abfrage (Tabelle) bewerkstelligen.
Erschwerend ist das ich nur spezielle Runden SELECTe.
1.SELECT
SELECT `t_ID_f`, SUM(`punkte`) FROM `resultate`, teams
WHERE teams.Liga='A'
AND teams.PlayOff=1
AND resultate.runde>7
AND resultate.t_ID_f=teams.t_id
OR teams.Liga='A'
AND teams.PlayOff=1
AND resultate.runde=-1
AND resultate.t_ID_f=teams.t_id
GROUP BY resultate.t_ID_f
ORDER BY sum(punkte) DESC
2.SELECT
SELECT `t_ID_f`, SUM(`punkte`) FROM `resultate`, teams
WHERE teams.Liga='A'
AND teams.PlayOff=2
AND resultate.runde>7
AND resultate.t_ID_f=teams.t_id
OR teams.Liga='A'
AND teams.PlayOff=2
AND resultate.runde=-1
AND resultate.t_ID_f=teams.t_id
GROUP BY resultate.t_ID_f
ORDER BY sum(punkte) DESC
1=oberes Play Off für Runde -1 und ab 7 (Runde -1 sind Bonuspunkte)
2=unteres Play Off für Runde -1 und ab 7
Habe es mit UNION probiert jedoch Fehlermeldung wegen Group by bekommen.
Geht das überhaupt sonst muss ich die 2 Abfragen in PHP in eine Tabelle überführen.
Bitte um einen Hinweis.
LG Gerhardus
habe folgendes Problem: 2 SELECT's aus 1 Tabelle mit 8 teams, xrunden und Punkten
möchte ich in einer Abfrage in ein oberes und unteres Play OFF
teilen. Beide Abfrage funktionieren für sich korrekt. Ich möchte jedoch dies in einer Abfrage (Tabelle) bewerkstelligen.
Erschwerend ist das ich nur spezielle Runden SELECTe.
1.SELECT
SELECT `t_ID_f`, SUM(`punkte`) FROM `resultate`, teams
WHERE teams.Liga='A'
AND teams.PlayOff=1
AND resultate.runde>7
AND resultate.t_ID_f=teams.t_id
OR teams.Liga='A'
AND teams.PlayOff=1
AND resultate.runde=-1
AND resultate.t_ID_f=teams.t_id
GROUP BY resultate.t_ID_f
ORDER BY sum(punkte) DESC
2.SELECT
SELECT `t_ID_f`, SUM(`punkte`) FROM `resultate`, teams
WHERE teams.Liga='A'
AND teams.PlayOff=2
AND resultate.runde>7
AND resultate.t_ID_f=teams.t_id
OR teams.Liga='A'
AND teams.PlayOff=2
AND resultate.runde=-1
AND resultate.t_ID_f=teams.t_id
GROUP BY resultate.t_ID_f
ORDER BY sum(punkte) DESC
1=oberes Play Off für Runde -1 und ab 7 (Runde -1 sind Bonuspunkte)
2=unteres Play Off für Runde -1 und ab 7
Habe es mit UNION probiert jedoch Fehlermeldung wegen Group by bekommen.
Geht das überhaupt sonst muss ich die 2 Abfragen in PHP in eine Tabelle überführen.
Bitte um einen Hinweis.
LG Gerhardus