Return multiple fields when doing MAX calculation

Z

zwestbrook

I need to return the max value of field "b" and the associated values
for fields "a" and "c."

My query looks like the following (where "2" is the average of all
responses for the given question):

qID 2 questionTXT
q1 2.97222222222222 Are the deliverables of milestones met?
q2 3.02777777777778 Is the vendor response to the escalation process
met?
q3 2.72222222222222 How would you rate the timeliness of deliverables?
q4 3.46666666666667 Is the Change Management Process followed?

The values are going to change over time, and I want to return the MIN
and MAX results with the corresponding question on a report
programmatically. I can modify the criteria of the query to return the
MIN and MAX averages, but don't know how to return the corresponding
question ID or question TXT. Ideas?
 
T

twoodmore via AccessMonster.com

Select a, c, max(b)
from tablename
group by a, c
I need to return the max value of field "b" and the associated values
for fields "a" and "c."

My query looks like the following (where "2" is the average of all
responses for the given question):

qID 2 questionTXT
q1 2.97222222222222 Are the deliverables of milestones met?
q2 3.02777777777778 Is the vendor response to the escalation process
met?
q3 2.72222222222222 How would you rate the timeliness of deliverables?
q4 3.46666666666667 Is the Change Management Process followed?

The values are going to change over time, and I want to return the MIN
and MAX results with the corresponding question on a report
programmatically. I can modify the criteria of the query to return the
MIN and MAX averages, but don't know how to return the corresponding
question ID or question TXT. Ideas?
 
Z

zwestbrook

Select a, c, max(b)
from tablename
group by a, c

Unfortunately this did not work as expected...perhaps due to my query?

Result:
questionID questionTXT MaxOf2
q1 Are the deliverables of milestones met? 2.97222222222222
q10 Does the vendor proactively initiate process/product/service
improvements? 2.73529411764706
q11 Does the quality of deliverables meet requirements?
2.72222222222222
q12 Does the vendor provide flexibility in responding to unscheduled
events/requirements? 2.94444444444444
q13 How would you rate the degree of product knowledge compared to
current platforms? 2.94117647058824
q14 Are the software releases, upgrades, and patch installations
complete and error free? 2.51515151515152
q15 How would you rate your overall perception of Quality?
2.72222222222222
q16 Does the vendor have adequate resources with authority to address
needs? 2.74285714285714
q17 Does the vendor provide proactive identification of new,
innovative technologies? 2.73529411764706
q18 Does the vendor provide cost and pricing transparency
negotiations? 2.93333333333333
q19 Does the vendor understand and respect guiding principles?
3.03225806451613
q2 Is the vendor response to the escalation process met?
3.02777777777778
q20 Does the vendor commit to enhancing the business relationship?
3.08823529411765
q21 How would you rate your overall perception of Partnership and
Technology? 2.88571428571429
q3 How would you rate the timeliness of deliverables? 2.72222222222222
q4 Is the Change Management Process followed? 3.46666666666667
q5 How would you rate your overall perception of Delivery and Support?
2.86111111111111
q6 Are the invoice contents correct or are errors corrected within 30
days? 3.18181818181818
q7 Is the bill clarity and structure formatted as requested by
Finance? 3.55555555555556
q8 Do the invoices arrive as agreed and on time? 2.90909090909091
q9 How would you rate your overall perception of Flexibility?
2.81818181818182

SQL:
SELECT tbl_QuestionList.questionID, tbl_QuestionList.questionTXT,
Max(tbl_questions_avgs_Formatted.[2]) AS MaxOf2
FROM tbl_QuestionList INNER JOIN tbl_questions_avgs_Formatted ON
tbl_QuestionList.questionID = tbl_questions_avgs_Formatted.[1]
GROUP BY tbl_QuestionList.questionID, tbl_QuestionList.questionTXT;

Expected Result:
q7 Is the bill clarity ...? 3.55555555555556 (MAX)
q14 Are the software ...? 2.51515151515152 (MIN)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top