question

Craig DIckson avatar image
0 Likes"
Craig DIckson asked Andrew O commented

ORDER BY not working in a SQL table query?

I am using a table query with SQL and it doesn't seem to be using the ORDER BY clause. What am I dong wrong?

Here is the query:

  1. Table tableBestLocation = Table.query("SELECT * FROM $1 ORDER BY 'CycleLastUsed' ASC LIMIT 600",Table("tableStorageStatus")); //
  2. tableBestLocation.cloneTo(Table("QueryDump"));

Here is the searched table:

1674524237765.png

And her is the result table:

1674523882635.png

With the

  1. ORDER BY 'CycleLastUsed' ASC

I expected (and wanted) the first row in the result to be LocationIndex 2, since its value of CycleLastUsed is lower than that of the first record. (Note that I am looking for the lowest, which may not be zero after a while.)

FlexSim 23.0.2
sqlorder by
1674523882635.png (13.0 KiB)
1674524237765.png (22.0 KiB)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered

You don't need the apostrophes around the field name - try without and it should work fine.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.