473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Sort (SQL) Query Results

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
2 1846
Delerna
1,134 Expert 1GB
ORDER BY category,region ASC
Dec 29 '08 #2
NeoPa
32,556 Expert Mod 16PB
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

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

Similar topics

6
by: Alan | last post by:
I'm just about to start a project that needs to combine the results of a SQL Server query with the results of an Index Server query. The basic idea is that the user enters/selects a bunch of search...
4
by: ETX | last post by:
Hello, My question is about the datagrid sorting. I have a datatable that is filled up with the data retrieved from an SQL query.I use that datatable as source for my datagrid. I would like to...
0
by: joseph speigle | last post by:
hi, To see the query results in native language see http://database.sarang.net/?inc=read&aid=5368&criteria=pgsql&subcrit=qna&id=&limit=20&keyword=&page=1 the simpler url is ...
0
by: Kaur | last post by:
Hi, I have created a report based on a cross tab query and would like to Sort the column heading of the report based on the sort order of another field. I have three tables called survey...
0
by: Kaur | last post by:
Hi, I have created a report based on a cross tab query and would like to Sort the column heading of the report based on the sort order of another field. I have three tables called survey...
6
by: Les Juby | last post by:
I need to extract records from a database subject to conditions and only thereafter give the users the choice of which fields to sort the results on. In this situation I can't write back to a...
6
by: Fuzzydave | last post by:
I am back developing futher our Python/CGI based web application run by a Postgres DB and as per usual I am having some issues. It Involves a lot of Legacy code. All the actual SQL Querys are...
9
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
7
by: itfetish | last post by:
Ok heres my problem, I have a database which has a table in it that has all the staff members who are currently signed out of hte office. That has their staff ID, and the time they are out till...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.