RE: SQL Query...HELP REQUIRED!

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,

While this may not be the ideal solution, I would do it with 2 queries. The
first creates the sum of the hours for each engineer, and then the second is
what you run to find the engineer with the lowest projected hours -

Query1:
Select Engineers, Sum(EstimatedJobHours) as TotalJobHours
FROM OngoingRequests
Group by e.Engineers

And then, Query 2:

SELECT Engineers
FROM Query1
WHERE Query1.TotalJobHours In (Select Min(TotalJobHours) from Query1);

Note that unless you need something other than the email address, based on
what you have provided, you do not need to link to tblSecurity to return the
email address.

Jim

"AQ" wrote:

> Hi,
>
> I am having a problem trying to generate a SQL query that will access my
> Access 2000 Database..... So you'll undrstand i'll just give you the names of
> the tables and the fields of which I am trying to query:
>
> Table Name: tblSecurity
> Field I'm trying to access: useremail
>
> Table Name: OngoingRequests
> Fields I'm trying to access: Engineer, EstimatedJobHours
>
> Note: Both useremail and Engineer hold email associated addresses
>
> I want to generate a SQL query that selects the useremail of the Engineer
> that has the least EstimatedJobHours when all EstimatedJobHours are added up
> for each Engineer.....
>
> In Pseudo Code I picture it like this:
> SELECT u.useremail
> FROM tblSecurity.u, OngoingRequests.e
> WHERE u.useremail = e.Engineers
> AND SUM(EstimatedJobHours) = MIN(of all SUM)
>
>
> The reason I need this query is because I want to send a service request
> (email) to the engineer in the database with the least amount of Estimated
> Job Hours....
>
> I hope this makes sense!! Any suggestions greatly appreciated.... ; )
>
.



Relevant Pages

  • Re: Find Number of Records for each office
    ... Totals button to convert the query to a Totals ... engineer fields, and "Count" for the affected files field. ... we have a major Lotus Notes database that I've pulled data from and we ...
    (microsoft.public.access.queries)
  • Re: ADSL bt engineer visit
    ... >> my query is if we order from any other isp who pays for the engineers ... > need for an engineer visit. ...
    (uk.telecom.broadband)
  • Re: Top 100
    ... Build a query sorted so that it goes top to bottom. ... Then create a second query, based on the first query, to resort and group it by Engineer and contract. ... My query has a list of all the products, qty, EngineerID and Contract he is on, with Product Group ...
    (microsoft.public.access.queries)
  • Re: Still need help with default value in combo box
    ... >Engineer (cboAsgEngID) is assigned to do a job. ... >data from a query: ... >cboSiteEngID, whilst still allowing users to make a change ...
    (microsoft.public.access.formscoding)
  • Problem sending an Email Via a Query?
    ... to send a service request form by email to the ... Engineer, EstimatedJobHours ... Both useremail and Engineer hold Service Engineer email addresses. ...
    (microsoft.public.windows.server.scripting)