Solved

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

Posted on 2000-02-28
15
156 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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