[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

SQL Syntax (TOUGH!)

Asked by mvasilevsky in Microsoft Access Database

Tags: Access 2003, SQL, Query, Subquery

I have a query that works great except the last column ("CumDollars") which should have the cumulative dollars + expenses. Right now it's adding the expenses on the specific line, but not carrying them in the cumulative sum. See the attached .xls file: the "CumDollars" column is what I get, the "Desired" column is what I want. I've attached a simplified copy of the database as well so you can understand my data structure. qry_Rpt_Weekly is the query in question.
Any help is appreciated!
Best,

MV
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
SELECT tbl_ActualHours.AcHDate, 
Sum(IIf([SysActTaskTypeNumber]=1,[AcHHours],0)) AS [Support Hours], 
Sum(IIf([SysActTaskTypeNumber]=2,[AcHHours],0)) AS [PM Hours], 
Sum(IIf([SysActTaskTypeNumber]=1,[AcHHours]*[AcHRate],0)) AS [Support Dollars], 
Sum(IIf([SysActTaskTypeNumber]=2,[AcHHours]*[AcHRate],0)) AS [PM Dollars], 
Sum(tbl_ActualHours.AcHHours) AS [Total Hours], Sum([AcHHours]*[AcHRate]) AS [Total Dollars], (SELECT Sum([AcHHours]) AS SumOfAcHHours FROM tbl_ActualHours AS t INNER JOIN tbl_SystemActivityTasks ON t.AcHSysActTaskNumber = tbl_SystemActivityTasks.SysActTaskID WHERE t.AcHDate<=tbl_ActualHours.[AcHDate] AND [ProjectNumber]=Forms!frm_Main!Projects) AS CumHours,
CDbl((SELECT nz(Sum(tbl_ActualExpenses.AcEDollars),0) AS SumOfAcEDollars 
FROM (tbl_Clients INNER JOIN tbl_Projects ON tbl_Clients.CltID = tbl_Projects.PjtClientNumber) INNER JOIN (tbl_Expenses INNER JOIN tbl_ActualExpenses ON tbl_Expenses.ExpID = tbl_ActualExpenses.AcEExpenseNumber) ON tbl_Projects.PjtID = tbl_Expenses.ExpProjectNumber WHERE tbl_Projects.PjtID=206 AND tbl_ActualExpenses.AcEDate=tbl_ActualHours.AcHDate)) AS Expenses, 
(SELECT Sum(t.[AcHHours]*t.[AcHRate]) AS SumofAcHDollars FROM tbl_ActualHours AS t INNER JOIN tbl_SystemActivityTasks ON t.AcHSysActTaskNumber = tbl_SystemActivityTasks.SysActTaskID WHERE t.AcHDate<=tbl_ActualHours.AcHDate AND [ProjectNumber]=Forms!frm_Main!Projects)+CDbl((SELECT nz(Sum(tbl_ActualExpenses.AcEDollars),0) AS SumOfAcEDollars 
FROM (tbl_Clients INNER JOIN tbl_Projects ON tbl_Clients.CltID = tbl_Projects.PjtClientNumber) INNER JOIN (tbl_Expenses INNER JOIN tbl_ActualExpenses ON tbl_Expenses.ExpID = tbl_ActualExpenses.AcEExpenseNumber) ON tbl_Projects.PjtID = tbl_Expenses.ExpProjectNumber WHERE tbl_Projects.PjtID=206 AND tbl_ActualExpenses.AcEDate=tbl_ActualHours.AcHDate)) AS CumDollars
FROM ((tbl_Clients INNER JOIN tbl_Projects ON tbl_Clients.CltID = tbl_Projects.PjtClientNumber) INNER JOIN tbl_SystemActivityTasks ON tbl_Projects.PjtID = tbl_SystemActivityTasks.ProjectNumber) INNER JOIN tbl_ActualHours ON tbl_SystemActivityTasks.SysActTaskID = tbl_ActualHours.AcHSysActTaskNumber
WHERE (((tbl_Clients.CltName)<>"ABCDE") AND ((tbl_Projects.PjtID)=206))
GROUP BY tbl_ActualHours.AcHDate;
Attachments:
 
Desired Output Example
 
 
Database
 
[+][-]11/04/09 04:36 AM, ID: 25738655Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Microsoft Access Database
Tags: Access 2003, SQL, Query, Subquery
Sign Up Now!
Solution Provided By: harfang
Participating Experts: 1
Solution Grade: A
 
[+][-]11/04/09 09:07 AM, ID: 25741475Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/04/09 02:13 PM, ID: 25744587Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625