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:

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

Here is the searched table:

1674524237765.png

And her is the result table:

1674523882635.png

With the

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.

Andrew O avatar image Andrew O commented ·

Hi @Craig DIckson, was Jason Lightfoot's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

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.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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