ORDER BY not working

I have a database where ORDER is very important. In 3 different database browsers ORDER BY works fine. Cut and paste the SQL to RB 2012 r2 and the order of the records is wrong. It doesn’t make any sense to me. Anyone have a clue what could be happening?

The code is pretty simple

SELECT * FROM [FF_NotEnoughCourses]
ORDER BY aa_school_code, aa_major_code, aa_student_id, aa_sg_last_update DESC;

Even if I move the ORDER BY to a view, it works in the browser but not in RB

Just downloaded Xojo and it does the same thing.

  1. what database engine ?
  2. what “browsers” are you using ?

seem like your SQL statement is only ORDER BY ??? DESC for the last one which is aa_sg_last_update

are any of the fields “text/string” datatypes?
and if so do they contain numeric values?


would be your “order” by and it would be correct

what kind of format for “aa_sg_last_update” field?? if it is a date field, best to use YYYY-MM-DD to sort properly

You mean move this entire SELECT to a view?

It works fine on every computer I’ve tested on except this one. So I compiled the code and it works fine. very strange.
The first 3 are Integers and the last one in the Order by is a date in SQL format. It’s the first one that goes wonky I get 121111111222232222

for aa_school_code BUT not after I compile.

Please, check Norman’s questions. :wink:


sqlite database browser 1, 2
sqlitestudio 2.1.4

[quote=13275:@Jym Morton]REALSqlite
Not sure which you’re referring to since we dont have one named that - REALSQLDatabase or SQLiteDatabase ?
It makes a difference
But I cannot imagine how it would affect the ordering

How did you you create this DB? By code or using your DB tools?

Using db tools… I used sqlitemanager which is excellent tools.