Autor Beitrag
DarkHunter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 477

Win XP
D3 Prof, D2005 PE
BeitragVerfasst: Sa 04.02.06 12:27 
Hallo,

ich in auf der Suche nach einem SQL-Befehl für eine spezielle Abfrage.
Ich habe zwei Tabellen, in der einen werden stehen Teilnehmer (name etc) in der anderen werden diesen Teilnehmern Punkte zugeorndet.

Nun möchte ich alle Teilnehmer ausgeben und die Punkte die sie erreicht haben, wenn es geht auch durchschnittspunkte:

BSP:
Teilnehmer :
1 A
2 B
3 C
Punkte:
1 A -> 12
2 B -> 7
3 C -> 20
4 A -> 3
5 B ->12
Ausgabe soll dann so aussehen:
A : 15 Punkte / 2 Turniere
B : 17 Punkte / 2 Turniere
C : 20 Punkte / 1 Turnier

_________________
I believe that every human has a finite number of heart-beats. I don't intend to waste any of mine running around doing exercises.
- Neil Armstrong
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Sa 04.02.06 12:38 
ausblenden SQL-Anweisung
1:
select sum(punkte)as gesamtpunkte, avg(punkte) as durchschnitt from punkte group by teilnehmer					

_________________
Markus Kinzler.
DarkHunter Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 477

Win XP
D3 Prof, D2005 PE
BeitragVerfasst: Sa 04.02.06 13:11 
Danke, erstmal das klappt soweit.

Nur wie schaffe ich es jetzt auch noch an die anderen Daten des Teilnehmers ranzukommen?

_________________
I believe that every human has a finite number of heart-beats. I don't intend to waste any of mine running around doing exercises.
- Neil Armstrong
afk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 102

Win 2K, Win XP
Delphi 2006 Arch., Delphi 6 Ent., MS-SQL 2005 & 2000
BeitragVerfasst: Sa 04.02.06 14:37 
ausblenden SQL-Anweisung
1:
2:
3:
4:
5:
6:
7:
8:
Select 
  T.Teilnehmer_Feld as Teilnehmer, 
  Sum(P.Punkte_Feld) as GesamtPunkte, 
  Count(*) as Tuniere 
from Punkte_Tabelle as P
  inner join Teilnehmer_Tabelle as T
    on T.TeilnehmerID = P.TeilnehmerID
group by T.Teilnehmer_Feld

Ich hoffe das entspricht einigermaßen der Tabellenstruktur, die ging aus der Anfrage leider nicht so richtig hervor.

Gruß Axel

_________________
Man muß sparn wo mn knn !
DarkHunter Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 477

Win XP
D3 Prof, D2005 PE
BeitragVerfasst: Sa 04.02.06 15:00 
Vielen Danke,
der befehl war genau das was ich gebraucht habe.

_________________
I believe that every human has a finite number of heart-beats. I don't intend to waste any of mine running around doing exercises.
- Neil Armstrong