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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP!! with complex recursive date query!

Status
Not open for further replies.

rubetube56

Programmer
Jan 26, 2007
3
US
Hello all,

I need help writing a 'recursive' date query where the user would enter in the date range (ex. 1/05/06 - 11/11/06). What I want the query to do is go through each month and count up the number of orders, then go through all of the orders and give a total number of orders. Sounds simple in principle, but I just can't figure it out.

Any help is greatly appreciated. Thanks!
 
How about
Code:
SELECT Sum(Order.Amount) AS SumOfAmount, Year([orderdate]) & "-" & Month([orderdate]) AS Mon
FROM Order
WHERE (((Order.orderdate) Between [startdate] And [enddate]))
GROUP BY Year([orderdate]) & "-" & Month([orderdate])
ORDER BY Year([orderdate]) & "-" & Month([orderdate]);
as a start?

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
perhaps if you post your table & field names along with some sample data and your expected results based on that sample, you'll get something a little closer to what you really need.

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for database developers:
The Fundamentals of Relational Database Design
Understanding SQL Joins
 
Well basically it didnt compile because I don't understand the Access SQL syntax that well.

For instance, I did not realize that Sum(Order.Amount) should be Sum([Order].[Amount]). That is just goofy SQL, that is why I don't understand Access that well.
 
actually you only need brackets around table and field names that contain a space.

[Table Name].[Field Name], TableName.FieldName is valid.

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for database developers:
The Fundamentals of Relational Database Design
Understanding SQL Joins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top