Solved

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

Posted on 2000-02-28
15
152 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
 

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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now