By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,940 Members | 614 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,940 IT Pros & Developers. It's quick & easy.

Sort (SQL) Query Results

P: 22
Hi People
I have a query with the following sql statement:
Expand|Select|Wrap|Line Numbers
  1. <cfquery name="showcategories" datasource="#dsn#">  
  2. SELECT fcategories.catID, region, category, description, 
  3. MAX(postdate) AS lastpost, COUNT(threadID) as postCount 
  4. FROM fcategories LEFT JOIN fthreads 
  5. ON fcategories.catID = fthreads.catID 
  6. GROUP BY fcategories.catID, region, category, description 
  7. ORDER BY category ASC
  8. </cfquery>
This returns all results i want ok but i would now like to sort the results also by region.( i have added a column in the fcategories table named region.
Can someone please help with how to do this)?

Cheers & thanks in advance
Grabit
Dec 29 '08 #1
Share this Question
Share on Google+
2 Replies


Delerna
Expert 100+
P: 1,134
ORDER BY category,region ASC
Dec 29 '08 #2

NeoPa
Expert Mod 15k+
P: 31,419
Line #7 simply needs to include all the fields you want to sort by, in the required order. The ASC part is not really required as it simply specifies the sorting be in ascending order (the default anyway).
Expand|Select|Wrap|Line Numbers
  1. ORDER BY category, region
PS. Please see the posting guidelines (Member Registration - Bytes) about how you should go about formulating your question. A meaningful title is a requirement. I have changed this one now to conform to the requirement.

Administrator.
Jan 7 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.