If you want to do this in SQL, you can use the DECODE function.  Let's say
you have a table called TASKS, and you want to prioritize TASK_Name by
TASK_Priority, High to Low:


SELECT TASK_Name, DECODE(TASK_Priority,'High',1,'Normal',2,'Low',3) AS
PriorityOrder
FROM TASKS
ORDER BY PriorityOrder


If you can't use DECODE because of your platform, you could also try the
tricky trick of using the third character in the TASK_Priority value, since
that works out the way you want it (g-r-w):


SELECT TASK_Name, SUBSTR(TASK_Priority,3,1) AS PriorityOrder
FROM TASKS
ORDER BY PriorityOrder


Finally, if you don't have SUBSTR either, you could do this clumsy bit:


SELECT TASK_Name, '1' AS PriorityOrder
FROM TASKS
WHERE TASK_Priority = 'High'
UNION
SELECT TASK_Name, '2' AS PriorityOrder
FROM TASKS
WHERE TASK_Priority = 'Normal'
UNION
SELECT TASK_Name, '3' AS PriorityOrder
FROM TASKS
WHERE TASK_Priority = 'Low'
ORDER BY PriorityOrder


HTH,
Matthieu

-----Original Message-----
From: Phillip Perry [mailto:[EMAIL PROTECTED]
Sent: Monday, October 11, 2004 12:31 PM
To: CF-Talk
Subject: grouping by...

Hi,

I want to arrange my data that is being displayed by the database field
"importance". I want High to be shown first, then Normal, then Low (which
are the 3 choices in the importance table"). How can i get Normal items to
show up before Low items?
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to