Total sum of a column

kikeman

Registered User.
Local time
Today, 17:04
Joined
Nov 20, 2009
Messages
13
Hi,

Is it possible to request for a total sum of a column (number type of course).

For example:
I have a table A with a column "Hrs" and a column "Date"
so that, I would like to SELECT the sum of all hours before certain date "myDate".

TableA
Hrs Date
4 11/2/2009
7 11/2/2009
5 11/3/2009
7 11/6/2009
7 11/8/2009

if myDate = "11/3/2009" then Result = 16 Hrs.

What would be the SELECT command to calculate the total of hours before myDate?

Thanks,
Enrique.
 
Make a Totals query, whilst your query is in design view click the Sigma button (Σ) Select Group By in your date column and Sum in your hours column.
 
Thanks my friend, I really need the SQL command because I am using OleDb from C# :)
 
Try creating the query and then going to SQL view, it should look something like;
Code:
SELECT TBL_dates.myDate, Sum(TBL_dates.Hrs) AS SumOfHrs
FROM TBL_dates
GROUP BY TBL_dates.myDate;
 
OleDbCommand SQLCommand3 = new OleDbCommand();
SQLCommand3.CommandText = "SELECT SUM(Tiempo_Empleado) FROM reporte_tiempo WHERE Depto = '" + AUser.Depto + "' AND ODT = '" + RepEach.ODT_Num + "'";
SQLCommand3.Connection = con;
double TotalHrs = (double)SQLCommand3.ExecuteScalar();
 

Users who are viewing this thread

Back
Top Bottom