Advertisement

02.29.2008 at 10:44AM PST, ID: 23204648
[x]
Attachment Details

How to sort by unique values instead of ascending or descending order?

Asked by sungenwang in SQL Query Syntax

Tags: SQL Syntax

Experts,

Looking at the data set below, if I need to sort first by fruit_type and then by country I would use the following sql: "SELECT * FROM MYTABLE ORDER BY fruit_type, country"

However, in this particular data set, it is sorted by fruit type but it is not in ASC or DESC order. Is there a way I can write a query to sort by fruit type using the specific fruit names? The table is a MSDE sql database.

Sample data set:
fruit_type,country
Banana, Canada
Banana, Canada
Banana, US
Banana, US
Apple, Canada
Apple, US
Orange, Canada
Orange, Canada
Orange, US
Orange, US
Orange, US
Start Free Trial
[+][-]02.29.2008 at 10:51AM PST, ID: 21016306

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.29.2008 at 10:57AM PST, ID: 21016360

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02.29.2008 at 10:57AM PST, ID: 21016361

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.29.2008 at 10:58AM PST, ID: 21016374

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.29.2008 at 11:02AM PST, ID: 21016405

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: SQL Query Syntax
Tags: SQL Syntax
Sign Up Now!
Solution Provided By: sdstuber
Participating Experts: 2
Solution Grade: A
 
 
[+][-]02.29.2008 at 11:06AM PST, ID: 21016450

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628