Advertisement

08.28.2008 at 06:57AM PDT, ID: 23685438
[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!

8.2

SQL SubQuery Syntax - MS Access

Asked by swilschutz in SQL Query Syntax

Tags: , ,

Hi,

I seem to be making a mistake in a subquery routine for MS Access. If I start with this:

SELECT t.employee, t.project, t.subproject, t.phase, t.notes, Sum(t.duration) AS hours, employee.fname, employee.lname, project.pname, subproject.subname
FROM ((timerecord AS t INNER JOIN employee ON t.employee = employee.empid) INNER JOIN project ON t.project = project.projectid) LEFT JOIN subproject ON t.subproject = subproject.subid
WHERE (((t.date)>=DLookUp("[startdate]","[Control]") And (t.date)<=DLookUp("[enddate]","[Control]")))
GROUP BY t.employee, t.project, t.subproject, t.phase, t.notes, employee.fname, employee.lname, project.pname, subproject.subname, employee.category
HAVING (t.project=83)
ORDER BY t.employee;

I get a summation of t.duration(AS hours) as expected. Then I add a subquery routine to the select clause (see below) to pick up one other piece of information. When I do that, the subquery returns the right value, but the summing values are changing in the outer query. For example: In the top query, the t.duration returns 17; in the bottom query it returns 68. 17 is the right number.

SELECT t.employee, t.project, t.subproject, t.phase, t.notes, Sum(t.duration) AS hours, employee.fname, employee.lname, project.pname, subproject.subname, (SELECT baserates.rate FROM baserates WHERE baserates.empid=t.employee AND baserates.begindate <=DLookUp("[startdate]","[Control]") And baserates.enddate >=DLookUp("[startdate]","[Control]")) AS rate
FROM (((timerecord AS t INNER JOIN employee ON t.employee=employee.empid) INNER JOIN project ON t.project=project.projectid) LEFT JOIN subproject ON t.subproject=subproject.subid) LEFT JOIN baserates ON employee.empid=baserates.empid
WHERE (((t.date)>=DLookUp("[startdate]","[Control]") And (t.date)<=DLookUp("[enddate]","[Control]")))
GROUP BY t.employee, t.project, t.subproject, t.phase, t.notes, employee.fname, employee.lname, project.pname, subproject.subname, employee.category
HAVING (t.project=83)
ORDER BY t.employee;

I'm not sure how much sense my description made. Let me know if you need any further information.

ThanksStart Free Trial
[+][-]08.28.2008 at 07:20AM PDT, ID: 22335148

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]08.28.2008 at 07:34AM PDT, ID: 22335332

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.28.2008 at 07:39AM PDT, ID: 22335401

View this solution now by starting your 7-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: SQL Query Syntax
Tags: Microsoft, Access, 2007
Sign Up Now!
Solution Provided By: swilschutz
Participating Experts: 1
Solution Grade: A
 
 
[+][-]08.28.2008 at 07:42AM PDT, ID: 22335439

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628