Solved

sum up of some fields of a table and store...

Posted on 2000-02-28
15
159 Views
Last Modified: 2010-04-04
hi,
i want to sum up some fields in a table for example with query2.sql.add('select sum(1) from zwischentab');, unfort. it doesnt work (with this code, m sure its wrongand i dont know why), what im trying in addition to store this sum in a specific field in another table. hope somebody has a good solution, thx
0
Comment
Question by:ugross
  • 8
  • 7
15 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 2567804
hi ugross,

what about this?

query2.close;
query2.clear;
query2.SQL.Add(Select Sum('+Table1.Fields[1].FieldName+') as Summe from tableName');
query2.Open;
tablex.FieldByName('NameOdTheSumField').Value := query2.FieldByName('Summe').Value;
query2.close;

explain a bit more what you want to do

meikl
0
 

Author Comment

by:ugross
ID: 2567817
looks good,thx. what im trying to set up is that in the following code the sumvalue in the tablex as u coded it will be taken to paint (canvas-like) points on a form and then show a chart.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2567829
hi ugross,

well, then try it and ask again in this q more specific if something not work as you want.

meikl
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:ugross
ID: 2576050
hi again, i tried it but i got an error telling unrecog. expression (as Summe), then tried to change some minor things to find the error, but no joy, i think there could be some basic things in my app. which r not that correct as they should be
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2576325
hi ugross,

seems that your database-system cannot aliasing fields.
try this change

query2.close;
query2.clear;
query2.SQL.Add(Select Sum('+Table1.Fields[1].FieldName+') from tableName');
query2.Open;
tablex.FieldByName('NameOdTheSumField').Value := query2.Fields[0].Value;
query2.close;

let me know if the error allways appears again

meikl
0
 

Author Comment

by:ugross
ID: 2576362
thx for the info, will try, and will inform u.
0
 

Author Comment

by:ugross
ID: 2599383
hi again, have tried this all, but no joy im getting an errormsg during runtime, in german it means "merkmal nicht verfuegbar" dont know what it means, in english it means "property not available" i think, any idea
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2599540
bad,

tell me what database you use,
and how you connect to it (odbc,native, third party)
will try to reproduce

btw. are you from germany?

meikl
0
 

Author Comment

by:ugross
ID: 2599559
yes im from germany,
im using the build in components of delphi 3 c/s means im using here 2 table components and a query to make this happen
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2599585
ja, schon wieder ein deutscher :-))

mit database meinte ich, welche datenbank benutzt du -> access, paradox, mssql, etc.
und wie du die verbindung zur datenbank aufbaust -> odbc-treiber, native bde treiber, bde replacment treiber, etc.

meikl
0
 

Author Comment

by:ugross
ID: 2599593
sorry hatte ich vergesse, benutze die bde zur admin., paradoxtabellen, eigentlich nur das was delphi selbst mittels treiber (ueber die bde) zur verfuegung stellt.danke
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2599659
ok,
sollte überhaupt kein problem sein.
habe noch d3 daheim.
wenn du deine eMail adresse hier hinterläßt, dann kann ich dir morgen oder übermorgen eine kleine Beispielanwendung schicken, die du dann mit deiner app vergleichen kannst.
(nur wenn du willst)

meikl
0
 

Author Comment

by:ugross
ID: 2599718
vielen dank mach ich gerne, meine e-mail ist ugross@bloomberg.net (begrenzt auf 2mb atachments), schau ich mir dann gleich an, ich nehme an es haengt an einer winzigkeit. danke
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2599758
yup,
denke ich auch das es nur ne kleinigkeit ist und 2 MB brauch ich keinesfalls.

ich schicks dir sobald ich fertig bin, nur heute klappts noch nicht, da ich erst spät heimkommen werde. wird also schon frühestens morgen abend, wahrscheinlich aber samstag im laufe des tages.

bis dann

meikl
0
 

Author Comment

by:ugross
ID: 2599765
wenns am wochenende ist dann schicks doch bitte an die e-mail grossu@t-online.de die ist zuhause dann hab ichs gleich in der ide, super, vielen dank
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi XE10 Round Image 2 162
JAudiorecorder record freezing the app 29 76
update joined tables 2 55
Why  'Host Connection unavailable/Socket Error #113 No route to host' 6 54
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question