ORDER BY not working in a SQL table query?

ORDER BY not working in a SQL table query?

craig_dickson
Not applicable
428 Views
2 Replies
Message 1 of 3

ORDER BY not working in a SQL table query?

craig_dickson
Not applicable

[ FlexSim 23.0.2 ]

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.)

0 Likes
Accepted solutions (1)
429 Views
2 Replies
Replies (2)
Message 2 of 3

jason_lightfootVL7B4
Autodesk
Autodesk
Accepted solution

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

0 Likes
Message 3 of 3

andrew_o2
Not applicable

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