MySQL Ordering question - yet another question!
Ok, have the following code:
SELECT q21 as Comment, q21coding AS Description
FROM `tresults_acme`
WHERE q21 IS NOT NULL AND q21 <> ''
ORDER BY q21coding = 'Other', q21coding = 'Positive comments', Count ASC
This brings back the following (excerpt):
Text Description
Lack of up to date equal pay cases&legislation - t... Content needs updating
The intranet could contain more "up to date traini... Content needs updating
Poorly set out. It is hard to find things. Difficulty in navigating/finding content
Only use the intranet as a necessity. Will ask my ... Difficulty in navigating/finding content
Never really use it too difficult to be honest, s ... Difficulty in navigating/finding content
What I need to do is bring back the Text in a specific order basically this is where a COUNT for Description is in Ascending order - make sense?
So in the example above, the text for 'Di开发者_C百科fficulty in navigating/ finding conent' would come first as it has a count of 3, then 'Content needs updating' as it has a count of 2.
Any advice welcome!
Thanks as always,
Homer.
Not entirely sure if this would work (cannot test this right now):
SELECT q21 as Comment, q21coding AS Description, (SELECT COUNT(*) FROM `tresults_acme` as t_a WHERE t_a.q21coding = Description) AS Count
FROM `tresults_acme`
WHERE q21 IS NOT NULL AND q21 <> ''
ORDER BY q21coding = 'Other', q21coding = 'Positive comments', Count ASC
My dear u dont have to give the value of the attributes in the order by clause, this is the mistake u have made in the code. I am not sure but i think so after select q21 as Comment type of syntax also needs reconsideration.
精彩评论