Autor Beitrag
Henry
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 619

WinXP Prof. SP3
D6 Prof.
BeitragVerfasst: Di 03.09.02 11:27 
Hallo,

wie kann ich in einer vorhandenen Paradox- Datenbank
in einem Datenfeld in dem ich eine Nummerierung vornehme
herausfinden welche Zahl die höchste ist, ohne jeden
Datensatz in einer IF-Schleife abfragen zu müßen?
Die Datensätze sind nämlich nicht nach diesem Feld sortiert.

Ist das irgendwie möglich?

Danke im Voraus.

_________________
mfg Henry
bis11
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: Di 03.09.02 11:32 
Das kannst Du über folgenden SQL-Befehl machen :

SELECT MAX(Datenfeld) FROM tabellenname

Das ganze kannst Du über eine TQuery-Kompo realisieren.
ao
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 145

Win XP Prof.
D7 Ent.
BeitragVerfasst: Di 03.09.02 11:33 
Hallo Henry,

ich würde mit einem SQL-Statement versuchen:

ausblenden Quelltext
1:
SELECT MAX(DeinFeld) FROM DeineTabelle					


Gruß
Andreas
ao
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 145

Win XP Prof.
D7 Ent.
BeitragVerfasst: Di 03.09.02 11:34 
@bis11
warst wohl ne Minute schneller als ich ... :wink:
bis11
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: Di 03.09.02 11:35 
@ao

tja das machen die Zauberfinger und DSL aus.
Henry Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 619

WinXP Prof. SP3
D6 Prof.
BeitragVerfasst: Di 03.09.02 11:36 
Genau so etwas habe ich mir vorgestellt (eine Zeile).
Aber giebt es da auch etwas fur Di TTable Kompo?
Habe mich nämlich noch nicht mit der SQL Kompo
beschäftigt.

_________________
mfg Henry
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Di 03.09.02 12:13 
Henry hat folgendes geschrieben:
Aber giebt es da auch etwas fur Di TTable Kompo?
Habe mich nämlich noch nicht mit der SQL Kompo
beschäftigt.

Nein, das geht meines wissens nicht. Wenn du halbwgs Professionell Datenbankprogrammierung betreiben willst musst du dich früher oder Später mit SQL auseinander setzen. Früher ist besser. Das die tQuery Komponente der tTable sehr änhnlich ist (haben beide den selben vorfahren) kannst du hier nachlesen. Dieses SQL-Buch bietet ein gutes Preis/Leistungs verhältnis.

Gruß
Klabautermann
Henry Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 619

WinXP Prof. SP3
D6 Prof.
BeitragVerfasst: Di 03.09.02 13:02 
Das wollte ich zwr eigentlich vermeiden, aber sieht so aus als wenn ich da nicht drum herum komme :)
Dann wede ich mal damit anfangen.

Danke euch für eure Hilfe, werde mich aber bestimmt wärend meiner
Beschäftigungsphase nochmal melden nochmal :D :D

_________________
mfg Henry
MrSpock
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 262



BeitragVerfasst: Di 03.09.02 14:54 
Hallo Henry,

wenn du wirklich SQL vermeiden willst, ist ein Schleifendurchlauf durch die Tabelle trotzdem möglich, auch wenn oder besser gerade wenn die Werte nicht sortiert sind (hier ein Beispiel für Integer):

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
maxVal := 0;
MyTable.First;
while Not MyTable.EOF do
begin
  if MyTable.FieldByName('DerWert').AsInteger > maxVal then
    maxVal := MyTable.FieldByName('DerWert').AsInteger;
  MyTable.Next;
end;


Alternativ kannst du auch einen Index (ggf. Sekundärindex) anlegen und diesen auswählen, dann wird die entsprechende Spalte sortiert und je nach Art der Sortierung steht der größte Wert am Anfang bzw. Ende der Tabelle. Aber das SQL Statement bleibt die beste Alternative.

_________________
Live long and prosper
MrSpock \\//