Adding Values ​​to a Column

Hi, I have a DBGrid with an AdoTable dataset, my column headings include “Job ID”, “Travel ID” and “Travel cost”. I would like to be able to add Travel costs together to create a total travel expense. I also have the following code that filters the travel ID, which is successfully displayed when searching for the Job ID,

DBTravel.DataSource.DataSet.DisableControls; DBTravel.DataSource.DataSet.Filtered := False; DBTravel.DataSource.DataSet.Filter := 'Job_ID = ' + edtSearchJobID.Text; DBTravel.DataSource.DataSet.Filtered := True; DBTravel.DataSource.DataSet.First; DBTravel.DataSource.DataSet.EnableControls; 

each Job has many travel expenses, so each job identifier has many travel identifiers, as well as the cost of business trips, in the end I would like the total amount of travel expenses to be added only to those “trip costs” that are displayed through the filter, t .e. The total amount of travel expenses includes only "Travel expenses" with a job identifier that is edtSearchJobID.Text and is displayed in dbgrid after the search. thanks

+4
source share
1 answer

You must use Aggregates and Groupings to summarize Travel Costs , filtered Job ID :

+6
source

Source: https://habr.com/ru/post/1403256/


All Articles