Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query help with totals?

Status
Not open for further replies.

que4life

Programmer
Feb 15, 2005
7
US
I have a table that has the a L_Date field and a L_Totals field. What I am trying to do is write a query that will give me the totals for a specific time period. I have a queries that produced the grand total for all entries (which I dont need) and I have a query that gives me the daily totals for the beginning and ending dates. But what I need is a query that will give me for example the one grand total for lets say 1/1/2004 and 1/9/2004....

Thanks in advance
 
A cool tool is to use the FORMAT function to group your date variables, if it works for you. For example...

SELECT Sum(L_Totals), Format(L_Date, "yyyy-mm ww")
FROM YourTable
GROUP BY Format(L_Date, "yyyy-mm ww")
Order By Format(L_Date, "yyyy-mm ww")

Richard

This would group your totals
 
A cool tool is to use the FORMAT function to group your date variables, if it works for you. For example...

SELECT Sum(L_Totals), Format(L_Date, "yyyy-mm ww")
FROM YourTable
GROUP BY Format(L_Date, "yyyy-mm ww")
Order By Format(L_Date, "yyyy-mm ww")

This would group your totals by year, month and week

Richard

 
Richard,
Thanks but I still need to return just one total for the selected time period. Can this FORMAT function be modified to accept two date parameters to return on record with the total for the designated time period?

dollarbillg
 
SELECT Sum(Table2.L_Total) AS SumOfL_Total
FROM Table2
WHERE (((Table2.L_Date) Between [Enter Start Date] And [Enter End Date]));
 
SuicidED,
Thank you very much!! That is just what I needed!!!
dollarbillg
 
How would I insert the Start and End Date values into Table2?
 
Hi

Bit lost what you want now. The query asks for a start date and end date you do not insert these into table 2 they are merely the parameters of the data you wish to retrieve. If you wish to record what you've asked for on a report or form, put the control source as =[Enter Start Date] for one box and ={enter End Date] for another.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top