MySQL Arbitrary Ordering Of Group By -


i have sql query looks like

select fruit, count(*) table1 group fruit 

it returns

grape 8
apple 2
peach 9
orange 6
banana 5

i not wish sort alphabetically.

i want in order

banana
apple
orange
peach
grape

i cant seem syntax right on case stamens.....help!

you use field() function:

select fruit, count(*) table1 group fruit order field(fruit, 'banana','apple','orange','peach','grape') 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -