Autor Beitrag
Karstadt
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 174

Windows 2000 / XP
Delphi 7 Pro
BeitragVerfasst: Mi 14.09.05 14:28 
Hallo.

Ich möchte gerne wissen wie ich eine Spalte summiere und den Summierten wert an einen String übergebe.

Die Select SUM(Spaltenname) habe ich schon ausprobiert, aber es wir in eine Tabelle zurückgegeben, ich häte das gerne als String.

Muss ich diese Tabelle in einen String auslesen oder gibt es eine direkte Funktion ?
neojones
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1206
Erhaltene Danke: 1



BeitragVerfasst: Do 15.09.05 09:54 
Du führst das in einer Query-Komponente aus, sagst ihr

ausblenden SQL-Anweisung
1:
SELECT SUM(feld) AS meinfeld					


und dann

ausblenden Delphi-Quelltext
1:
MeinString := MeineQuery.FieldByName('meinfeld').AsString					


Viele Grüße,

Matthias

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
Moderiert von user profile iconKlabautermann: Code- durch SQL.Tags ersetzt.

_________________
Ha! Es compiliert! Wir können ausliefern!
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6393
Erhaltene Danke: 147

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 15.09.05 11:14 
Was auch ginge:
ausblenden Delphi-Quelltext
1:
MeinString := MeineQuery.Fields[0].AsString					

Dann ist es das erste Feld deiner Query.
Karstadt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 174

Windows 2000 / XP
Delphi 7 Pro
BeitragVerfasst: Di 20.09.05 16:39 
Hallo. Als erstes danke für schnelle Hilfe!

So habe ich das auch gemacht.

Ich hätte das aber gerne anders.

Anfrage A

Daraus sol ich die Summe ausrechnen. Wenn ich die SELECT Anweisung anwenden wird die Anfrage A verloren gehen...

Können Sie mir folgen?

Ich hätte es gerne ohne verlust gemacht... geht das ?

bzw. Anfraga A dann kommt Sum und dann wiederholte ich die Anfrage A....