Nick Cartwright
Nick Cartwright

Reputation: 8274

Sqlite query - order results with numbers last

I would like to perform an SQLite query and order my results with numbers last.

Eg:

SQLite will ordinarily order results like this when I specify ASC on a text field:

0, 1, 2, A, B, C

Whereas I would like this:

A, B, C, 0, 1, 2

Any ideas? Is this possible?

Thanks!

Nick.

Upvotes: 3

Views: 1467

Answers (1)

davek
davek

Reputation: 22925

I know nothing about sqllite, but something like this should work (assuming, of course, that there is some sort of isnumeric function available):-

order by isnumeric(colA), colA

so that your non-numerics appear first.

Upvotes: 3

Related Questions