question

10Dulkar avatar image
0 Likes"
10Dulkar asked Jeanette F commented

SQL Help

I want to sort an array inside the table in assending order. Can someone help with SQL query for that. This is the table structure and Path column is the Array.

1670438164461.png



FlexSim 22.1.4
sql queries
1670438164461.png (9.5 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.

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

You can sort the table based on values in the array but not reorder the arrays stored in Path in via SQL in one query. So:


1670438807855.png


SQLsortUsingArrayValues.fsm

If those arrays were constructed from another table with SQL then you could sort it as part of the ARRAY_AGG grouping with and ORDER BY clause.


· 2
5 |100000

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

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered

You can query an array. Then you can order the result table. This table can be aggregated in another query to get an array back. You can probably do this over arrays in table tows by join and separate it in an ordered structure of a ROW_NUMBER clause. But my experience on this reaches not far enough to build this code structure. I hope you find someone who can do it.

5 |100000

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