• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Get Results For Most Wrong Answers

Participant ,
Apr 10, 2012 Apr 10, 2012

Copy link to clipboard

Copied

I've googled this to death and can't seem to get the right output...

I can get it close with the right amount of no answers for each question...

But I can't order it correctly by most answered no...

Any help is appreciated...

Basically I want to order them by the most amount of no answers first... etc...

Coding below gets me the proper output - but not ordered by most...

Changing to order by recordcount or QCount errors...

cfquery name="allans" datasource="#ds#">
SELECT
qid, count(qid) as Qcount
FROM answer
where answer = 'no'
GROUP BY qid
ORDER BY qid
cfquery>

<cfoutput query="allans" group=qid>    
<hr>#qid# - #QCount#<br>    
</cfoutput>

ColdFusion8 - MS Access Database

Any help is appreciated thx...

TOPICS
Advanced techniques

Views

702

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Apr 10, 2012 Apr 10, 2012

Correct... Trying to order by most answered no...

No go with GROUP BY count(qid) DESC

Order By works...

ORDER BY count(qid) desc

cfquery name="allans" datasource="#ds#">
SELECT
qid, count(qid) as Qcount
FROM answer
where answer = 'no'
GROUP BY qid
ORDER BY count(qid) desc
cfquery>

<cfoutput query="allans" group=qid>    
<hr>#qid# - #QCount#<br>    
</cfoutput>

Thanx Owain... I was trying to do order by QCount...

Not sure why I didn't try that one...

Thx

Votes

Translate

Translate
Guide ,
Apr 10, 2012 Apr 10, 2012

Copy link to clipboard

Copied

Well, take a look at your query - you're saying the value you want to order by is count(qid), is that right?

If so:

     GROUP BY count(qid) DESC

Should do you. Unless I've misunderstood?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 10, 2012 Apr 10, 2012

Copy link to clipboard

Copied

Correct... Trying to order by most answered no...

No go with GROUP BY count(qid) DESC

Order By works...

ORDER BY count(qid) desc

cfquery name="allans" datasource="#ds#">
SELECT
qid, count(qid) as Qcount
FROM answer
where answer = 'no'
GROUP BY qid
ORDER BY count(qid) desc
cfquery>

<cfoutput query="allans" group=qid>    
<hr>#qid# - #QCount#<br>    
</cfoutput>

Thanx Owain... I was trying to do order by QCount...

Not sure why I didn't try that one...

Thx

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 10, 2012 Apr 10, 2012

Copy link to clipboard

Copied

LATEST

Sorry, that was a brain>fingers error, clearly order by not group by!

Glad you got it sorted.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation