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

win 7
Turbo Delphi, VS 20010 Express
BeitragVerfasst: Mo 02.05.11 14:48 
Hallo

Mein Problem ist es per sql die zweit höhsten Punkte addieren.
z.B.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
Name   |Punkte|Punkte1|Punkte2|
-------------------------------
Maier  |1     |2      |3      |---> =5
-------------------------------
Fischer|6     |4      |5      |---> =11
-------------------------------
Bayer  |2     |0      |2      |---> =4


Also mit den addieren habe ich erst mal so gemacht.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
  with QSumme do
  begin
    Close;
    SQL.Clear;
    SQL.Add('update Tabelle set Gesamt = (Punkte + Punkte1 + Punkte2)');
    ExecSQL;
  end;

_________________
MfG
Tabakbrummel
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 02.05.11 15:28 
Moin!

Hm, Zeilensummen sind allerdings spannend... :?

Was Besseres fällt mir gerade nicht ein: :nixweiss:
ausblenden SQL-Anweisung
1:
UPDATE tmp SET gesamt = punkte1+punkte2+punkte3 -IF(punkte1 < IF(punkte2 < punkte3, punkte2, punkte3), punkte1, IF(punkte2 < punkte3, punkte2, punkte3))					
Da bin ich mal auf die SQL-Experten gespannt, das muss doch noch besser gehen. :zustimm:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Tabakbrummel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 124

win 7
Turbo Delphi, VS 20010 Express
BeitragVerfasst: Mo 02.05.11 15:41 
Hallo Narses

Funktioniert leider nicht. Da kommt die Fehlermeldung
Exception-Klasse EABSException mit Meldung 'Token ',' expected, but '-' found at line 1, column 54 - Native error: 30222'

_________________
MfG
Tabakbrummel
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 02.05.11 15:43 
Moin!

user profile iconTabakbrummel hat folgendes geschrieben Zum zitierten Posting springen:
Funktioniert leider nicht. Da kommt die Fehlermeldung
Nun, ich gebe zu, dass ich es im MySQL-Dialekt getestet habe. :? (und da funktioniert´s)

Probier mal den ganzen Ausdruck zu klammern. :idea: :nixweiss:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Tabakbrummel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 124

win 7
Turbo Delphi, VS 20010 Express
BeitragVerfasst: Mo 02.05.11 16:42 
Hallo Narses

Funktioniert leider auch nicht.

_________________
MfG
Tabakbrummel
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 03.05.11 08:18 
Moin!

user profile iconTabakbrummel hat folgendes geschrieben Zum zitierten Posting springen:
Funktioniert leider auch nicht.
Hm, schade. Ich gebe zu, ich kenne den von dir verwendeten SQL-Dialekt nicht. Kennt das DBMS evtl. kein IF? :nixweiss:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Di 03.05.11 08:48 
ausblenden SQL-Anweisung
1:
2:
3:
4:
5:
6:
7:
update tabelle as ziel
   set gesamt = (select max(p) from(
                  select punkte + punkte1 as p from tabelle where ziel.name = name
                  union
                  select punkte + punkte2 as p from tabelle where ziel.name = name
                  union
                  select punkt1 + punkte2 as p from tabelle where ziel.name = name))


Keine Ahnung, ob das mit Absolute Database funktioniert. Ich habe es bei mir auch nicht geprüft und nur mal schnell hingetippt.


Zuletzt bearbeitet von jasocul am Di 03.05.11 10:26, insgesamt 1-mal bearbeitet
Tabakbrummel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 124

win 7
Turbo Delphi, VS 20010 Express
BeitragVerfasst: Di 03.05.11 09:28 
Hallo Peter

Es funktioniert mit der Absolute Database. :dance2:
Und vielen Besten dank. :beer:

_________________
MfG
Tabakbrummel
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Di 03.05.11 10:28 
Gern geschehen, wundert mich aber, da noch eine Klammer fehlte. :rofl:
Ist jetzt aber korrigiert. :wink: