1

Example i have a table:

----------------------
 ID. | Color
----------------------
 A1.  | Red
 A2.  | Yellow
 A3.  | Blue
 A4.  | Black
-----------------------

Is this possible to sort a table like this? specify a field to be on top (example: Yellow) then the other records will be in alphabetical order. the Color field can only be sorted.

----------------------
 ID. | Color
----------------------
 A2.  | Yellow
 A4.  | Black
 A3.  | Blue
 A1.  | Red
-----------------------

Is there a query related to this? Thanks.

Diado
  • 2,229
  • 3
  • 18
  • 21
Melz
  • 13
  • 5

2 Answers2

1

You can use:

Select
    ID,
    Color
From
    YourTable
Order By
    Abs([Color] = "Yellow") Desc,
    Color Asc
Gustav
  • 53,498
  • 7
  • 29
  • 55
-1
select *
from something
order by
 case when Color = "Yellow"  then "1"
 else Color 
end
M.Ali
  • 67,945
  • 13
  • 101
  • 127