Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2000-02-28
15
Medium Priority
?
164 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
15 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 300 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

688 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