I am testing a sample application, which adds a number of individuals i.e., "people" and records a measure of time for each month of the year for each of these people i.e., "minTime" a decimal value, and "auxTime" a decimal value.
In my code, I iterate through a SQL database table in an effort to total the decimal values of each individual's hours. "person" is an nvarchar, and "yearTotal" is a decimal.
I want to display the totals in a ListView screen.
For testing purposes I have added 2-people. Each individual has a measure of time entered for each of the 12-months.
There are 2-problems I'm running into.
1) Attempting to add "yearTotal" to the ListView control, ends up displaying each month of the 12-months worth of data for each person.
For example: John Smith 50-hours, John Smith 75-hours, etc, rather than a total for John Smith, and this occurs for all the persons.
2) And as soon as "yearTotal" reaches the correct total for the first individual, it holds onto this value and increments it for the next person, giving a false value for all subsequent persons.
I need to know how (and where) to add each person's yearly total in ONE Entry to the ListView control, rather than multiple entries of the same person.
For example: John Smith 840-hours, Sally Jones 750-hours.
Here is a link to download a "testDB" with a single table named "timeRecord". Please bear in mind that I need a way to completely Total the values for each individual person, totaling their values from January through December and displaying that person's grand total in a ListView control.
When I've attempted to use SUM on the minTime and auxTime columns (with an alias) SQL still displays the individual month totals but not a single Grand Total for each person. sample database