Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
order
Syntax
1result = order rows by field [ asc | desc ];
2result = order rows by (field [ asc | desc ], field [ asc | desc ]);
3result = order rows by field [ asc | desc ] nulls [first | last];asc or desc specifies whether the results are ordered in ascending (asc) or descending (desc) order. The default order is ascending.
Usage
Use order to sort the results in a data stream for display. You can use order with ungrouped data. You can also use order to sort grouped data by an aggregated value.
Do not use order to specify the order that another SAQL statement or function will process records in. For example, do not use order before timeseries to change the order of processing. Instead, use timeseries parameters.
By default, nulls are sorted last when sorting in ascending order and first when sorting in descending order. You can change the ordering of nulls using nulls [first | last].
Example
Example
1a = load "0Fbxx000000002qCAA/0Fcxx000000002WCAQ";
2b = group a by (year, month);
3c = foreach b generate year as year, month as month;
4d = order c by (year desc, month desc);Example
1a = load "0Fbxx000000002qCAA/0Fcxx000000002WCAQ";
2b = load "0Fayy000000002qCAA/0Fbyy000000002WCAQ";
3c = cogroup a by year, b by year;
4c = order c by a.airlineName;
5c = foreach c generate year as year;Example
1q = order q by last_shipping_cost desc nulls last;Example
1q = load "0Fbxx000000002qCAA/0Fcxx000000002WCAQ";
2q = group q by 'FirstName';
3q = foreach q generate sum('mea_mm10M') as 'sum_mm10M';
4q = order q by 'FirstName' desc;1q = load "0Fbxx000000002qCAA/0Fcxx000000002WCAQ";
2q = group q by 'FirstName';
3q = foreach q generate 'FirstName' as 'User_FirstName', sum('mea_mm10M') as 'sum_mm10M';
4q = order q by 'User_FirstName' desc;