Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I am trying to order a column in access. The field name is Project Status and I would lilke to order it by red first yellow second and green third. Anyone knows how I can order that way?ThanksGoksu
X002548
Not Just a Number
15586 Posts
Posted - 2003-05-21 : 17:18:41
I here Mauve is a very fast database color...What are you talking about?Are you looking at an excel spreadsheet?Brett8-)
goksut
Starting Member
5 Posts
Posted - 2003-05-21 : 17:27:46
I am looking at Access as I mentioned and in the query I have written statements of "red" "yellow" "green". I would like to sort them in the order I asked above.
quote:I here Mauve is a very fast database color...What are you talking about?Are you looking at an excel spreadsheet?Brett8-)
izaltsman
A custom title
1139 Posts
Posted - 2003-05-21 : 18:25:36
Use iif() function to assign a numeric value to each of those colors like so:
SELECT MyMessedUpColors.color, IIf([color]="red",1,IIf([color]="yellow",2,3)) AS Expr1FROM MyMessedUpColorsORDER BY IIf([color]="red",1,IIf([color]="yellow",2,3));
ValterBorges
Master Smack Fu Yak Hacker
1429 Posts
Posted - 2003-05-21 : 19:08:13
You could also create an order table with two fields color, orderso it would havered 1yellow 2green 3Next do the following querySELECT *FROM MyTable A INNER JOIN ColorsTable B ON A.[Project Status] = B.colorORDER BY B.OrderIf you need a different order just change the table.
goksut
Starting Member
5 Posts
Posted - 2003-05-22 : 10:04:53
Thanks a lot.
quote:Use iif() function to assign a numeric value to each of those colors like so:
SELECT MyMessedUpColors.color, IIf([color]="red",1,IIf([color]="yellow",2,3)) AS Expr1FROM MyMessedUpColorsORDER BY IIf([color]="red",1,IIf([color]="yellow",2,3));
goksut
Starting Member
5 Posts
Posted - 2003-05-22 : 10:05:37
Thanks a lot.
quote:You could also create an order table with two fields color, orderso it would havered 1yellow 2green 3Next do the following querySELECT *FROM MyTable A INNER JOIN ColorsTable B ON A.[Project Status] = B.colorORDER BY B.OrderIf you need a different order just change the table.