Ranges and Finding the Result

R

rodgeraj

I've got two tables, really two queries that I need to kind of put
together.

The first table is a list of Goals, a rating system for production
standards like so

prod_tc prod_job goal_name goal_uph_min goal_max
Telecommuter Specialty Among the Best 15.50 60.00
Telecommuter Specialty Highly Successful 12.50 15.49
Telecommuter Specialty Successful 10.50 12.49
Telecommuter Specialty Mixed Results 8.50 10.49
Telecommuter Specialty Not Meeting 0.00 8.49

The query is an associate info query that shows the stats of each user

prod_user prod_tc prod_job prod_clms prod_min UPH
Mary Telecommuter Specialty 1514 8055 11.28
Mary Telecommuter Specialty 1154 7798 8.88
Mary Telecommuter Specialty 1997 7491 16.00
Mary Telecommuter Specialty 1284 5589 13.78
Mary Telecommuter Specialty 2603 8815 17.72
Mary Telecommuter Specialty 1533 6917 13.30
Mary Telecommuter Specialty 1763 6307 16.77
Mary Telecommuter Specialty 2359 10514 13.46

My Ultimate Goal is to join the two some how so that the query will
spit out what Goal_Name belongs with the UPH (a calculated field) ...
essentially something like this

prod_user prod_tc
prod_job prod_clms prod_min UPH goal_name
Mary Telecommuter Specialty 1514 8055 11.28 Successful
Mary Telecommuter Specialty 1154 7798 8.88 Mixed Results
Mary Telecommuter Specialty 1997 7491 16.00 Among the Best
Mary Telecommuter Specialty 1284 5589 13.78 Highly Successful
Mary Telecommuter Specialty 2603 8815 17.72 Among the Best
Mary Telecommuter Specialty 1533 6917 13.30 Highly Successful
Mary Telecommuter Specialty 1763 6307 16.77 Among the Best
Mary Telecommuter Specialty 2359 10514 13.46 Highly Successful

There are a number of prod_tc (Telecommuter or In Office) and a number
of prod_jobs (Specialty, Adjustor, etc.) so the query will have to
qualify

Where assoc_prod.prod_tc=joined_goal.prod_tc & assoc_prod.prod_job =
joined_goal.prod_job

Then return the value where the UPH is in the range and it returns the
goal_name.

This is likely something easy that I'm totally missing right now. I
hope I've explained well enough what I'm hoping for.

In advance, thank you for your help.
 
K

KARL DEWEY

Try this --
SELECT joined_goal.prod_user, joined_goal.prod_tc, joined_goal.prod_job,
joined_goal.prod_clms, joined_goal.prod_min, joined_goal.UPH,
assoc_prod.goal_name
FROM joined_goal LEFT JOIN assoc_prod ON (joined_goal.prod_job =
assoc_prod.prod_job) AND (joined_goal.prod_tc = assoc_prod.prod_tc)
WHERE (((joined_goal.UPH) Between [goal_uph_min] And [goal_max]));
 
Top