|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Summing issue
I know I'm having a brain fart..but any help would be appreciated
I have a table that has budgets for specific locations on specific dates. What I'm trying to do is to have it add up the budgets for a specific location between specific dates. For example, what was the combined budget for 4/1 and 4/2 for location A? It gives me the budget for 4/1 and then a separate line for 4/2. I want it to ADD the budgets for those two days. Here is what I have: SELECT Sum(tblAllBudgets.budgetAmt) AS SumOfbudgetAmt, tblAllBudgets.budgetDate FROM tblAllBudgets WHERE (((tblAllBudgets.budgetCompany)="BLO")) GROUP BY tblAllBudgets.budgetDate HAVING (((tblAllBudgets.budgetDate)>#3/31/2004# And (tblAllBudgets.budgetDate)<#4/3/2004#)); What is the obvious thing I'm missing? Thanks |
|
#2
|
||||
|
||||
|
provide table structure, some sample data and what you want the final result to look like.
|
|
#3
|
|||
|
|||
|
It's in Access 2k
Table structure is : table name tlbAllBudgets Colums are: budgetId(PK), budgetDate, budgetAmt, budgetBranch, budgetCompany Want to sum the budgets of all branches in a certain company between for the dates 4/1/2004 and 4/2/2004 Does that help? |
|
#4
|
||||
|
||||
|
need sample data and an example of how you want the returned results to look.
|
|
#5
|
|||
|
|||
|
tblAllBudgetsSample data
tblAllBudgets budgetId budgetDate budgetAmt budgetBranch budgetCompany 18 3/31/2004 $0.00 COS BLO 19 4/1/2004 $5000.29 COS BLO 20 4/2/2004 $5500.38 COS BLO And all I want it to do is tell me the budget amount for 4/1/2004 and 4/2/2004 for the two companies in BLO is $10500.67 |
|
#6
|
||||
|
||||
|
Try this
Code:
SELECT budgetCompany, SUM(budgetAmt) As 'Budget Amount' FROM TableName WHERE budgetCompany = 'BLO' AND (budgetDate BETWEEN '3/31/2004' AND '4/3/2004') GROUP BY budgetCompany Depending on the data type of your budgetDate field, you may need to surround the dates with # Last edited by Memnoch : June 23rd, 2004 at 05:18 PM. |
|
#7
|
|||
|
|||
|
THANK YOU THANK YOU THANK YOU
It was one of those things where I was making it WAY too hard. THANK YOU |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Summing issue |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|