I am looking to create a single query for the following:
I would like to capture a list of all products and their descriptions with ytd total, previous month, current month, and projected for next month.
All information is held in the same view as follows:
Product
ProductDescription
DisburseDate
This is how I would do it.
SQL Code:
You said you wanted totals, I assumed you had to have a Qty field.Code:SELECT ProductData.Product, ProductData.ProductDescription, Sum(IIf([ProductData]![DisburseDate]<=Date() And Year([ProductData]![DisburseDate])>=Year(Date()),[Qty],0)) AS YTD, Sum(IIf(Month([ProductData]![DisburseDate])=Month(Date()),[Qty],0)) AS [Current Month], Sum(IIf(Month([ProductData]![DisburseDate])=(Month(Date())+1),[Qty],0)) AS [Predicted Next Month] FROM ProductData GROUP BY ProductData.Product, ProductData.ProductDescription;
Hope this helps,
Dan
"I am not a rocket scientist, I am a nuclear engineer." - Split_atom18
If my advice has been helpful to you, then please help me by clicking on the scales and adding to my reputation, Thanks!
I do not have a quantity field, all entries are listed seperately on a per order basis.
K so remove [Qty] and place a 1 in there.
"I am not a rocket scientist, I am a nuclear engineer." - Split_atom18
If my advice has been helpful to you, then please help me by clicking on the scales and adding to my reputation, Thanks!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks