Autor Beitrag
Tabakbrummel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 124

win 7
Turbo Delphi, VS 20010 Express
BeitragVerfasst: Di 25.01.11 17:46 
Hallo

Ich habe erst mal ein kleines Ranking erstellt, das Funktioniert auch.
Mein Problem ist das Updaten, da kommt die Fehlermeldung "Exception-Klasse EABSException mit Meldung 'Token ',' expected, but 'FROM' found at line 3, column 1 - Native error: 30222'."

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.Button1Click(Sender: TObject);
begin
 with ABSQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('UPDATE Rank');
    SQL.Add('SET Platz = RankAuswertung.Platz');
    SQL.Add('FROM Rank');
    SQL.Add('INNER JOIN');
    SQL.Add('(SELECT ID, a1.Name,a1.Punkte,COUNT(a2.Punkte) Platz');
    SQL.Add('FROM Rank a2,Rank a1');
    SQL.Add('WHERE a1.Punkte < a2.Punkte or (a1.Punkte = a2.Punkte and a1.Name = a2.Name)');
    SQL.Add('GROUP BY a1.Name,a1.Punkte');
    SQL.Add('ORDER BY a1.Punkte DESC');
    SQL.Add('From Rank) as RankAuswertung');
    SQL.Add('on Rank.ID = RankAuswertung.ID');
    ExecSQL;
  end;
end;


Kann mir einer Bitte helfen. :?: :roll:
Und besten Dank im Vorraus.

_________________
MfG
Tabakbrummel


Zuletzt bearbeitet von Tabakbrummel am Mi 26.01.11 00:17, insgesamt 1-mal bearbeitet
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Di 25.01.11 18:05 
Du mischt hier ein UPDATE mit einem SELECT-Statement... bzw noch nicht mal ein ganzes Statement, eher so Fragmente.

Ehrlich gesagt ist mir auch nicht so wirklich klar was genau das Ganze dann tun soll - sieht etwas sehr verworren aus.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Tabakbrummel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 124

win 7
Turbo Delphi, VS 20010 Express
BeitragVerfasst: Di 25.01.11 18:11 
Hallo Martok

Also ich möchte aus den Statement Ranking das es in der Tabelle gespeichert wird.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
    SQL.Add('SELECT a1.Name, a1.Punkte, COUNT(a2.Punkte) Platz');
    SQL.Add('FROM Rank a2, Rank a1');
    SQL.Add('WHERE a1.Punkte < a2.Punkte or (a1.Punkte = a2.Punkte and a1.Name = a2.Name)');
    SQL.Add('GROUP BY a1.Name,a1.Punkte');
    SQL.Add('ORDER BY a1.Punkte DESC');

Und das mit den Ranking Funktioniert soweit.

_________________
MfG
Tabakbrummel
Tabakbrummel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 124

win 7
Turbo Delphi, VS 20010 Express
BeitragVerfasst: Do 27.01.11 19:55 
Hallo

Nun formeliere ich mal die Frage anders.
Ich möchte aus den Code das Ranking Updaten. Wie kann ich bewerkstelligen, oder geht das ränking auch anders? (Absoltute Database hat aber kein Rank()over)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
 with ABSQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select R1."Name", R1."Punkte", count(R2."Punkte") as "Platz" ');
    SQL.Add('from "Rank" R1, "Rank" R2');
    SQL.Add('where ((R1."Punkte" < R2."Punkte") or (R1."Punkte" = R2."Punkte" and R1."Name" = R2."Name"))');
    SQL.Add('group by R1."Punkte", R1."Name" ');
    SQL.Add('order by R1."Punkte" desc');
    open;
  end;


den orginalcode habe aus der Quelle www.1keydata.com/sql/sql-rank.html

_________________
MfG
Tabakbrummel