Search…
sort

Overview

The sort statement is used to re-order the rows in usage data

Syntax

sortdset.id [desc|descending]using|bycolumn_name [column_name ...]

Details

The sort statement will reorder the usage records in the specified DSET using one or more column names as the keys to sort by.
By default the sort will be done in ascending order but if the optional desc keyword is present after the DSET ID then the rows will be sorted in descending order.
Any number of columns to sort by may be specified but any given column name may only appear once in the list, the column names must not be fully qualified, and all the specified columns must exist in the data to be sorted.

Examples

Given the following data imported as the dset example.sort:
1
account,account2,service,quantity,rate,cogs,interval,instance,ref1,ref2
2
Account1,Subaccount1,ServiceX,100,1,0.5,monthly,Instance,zebra,echo
3
Account1,Subaccount2,ServiceY,100,1,0.5,daily,Instance2,delta,echo
4
Account1,Subaccount2,ServiceY,100,1,0.5,daily,Instance2,zebra,alpha
5
Account1,Subaccount2,ServiceY,100,1,0.5,daily,Instance2,delta,echo
6
Account1,Subaccount3,ServiceZ,100,1,0.5,individually,Instance3,charlie,zebra
7
Account1,Subaccount3,ServiceZ,100,1,0.5,individually,Instance3,charlie,bravo
8
Account1,Subaccount3,ServiceZ,100,1,0.5,individually,Instance3,charlie,romeo
9
Account2,Subaccount4,ServiceX,100,1,0.5,monthly,Instance,golf,tango
10
Account2,Subaccount4,ServiceY,100,1,0.5,daily,Instance2,sierra,papa
11
Account2,Subaccount4,ServiceZ,100,1,0.5,individually,Instance3,xray,papa
Copied!
... the following statement:
sort example.sort by ref1 ref2
... will reorder the usage records as follows.
1
account,account2,service,quantity,rate,cogs,interval,instance,ref1,ref2
2
Account1,Subaccount3,ServiceZ,100,1,0.5,individually,Instance3,charlie,bravo
3
Account1,Subaccount3,ServiceZ,100,1,0.5,individually,Instance3,charlie,romeo
4
Account1,Subaccount3,ServiceZ,100,1,0.5,individually,Instance3,charlie,zebra
5
Account1,Subaccount2,ServiceY,100,1,0.5,daily,Instance2,delta,echo
6
Account1,Subaccount2,ServiceY,100,1,0.5,daily,Instance2,delta,echo
7
Account2,Subaccount4,ServiceX,100,1,0.5,monthly,Instance,golf,tango
8
Account2,Subaccount4,ServiceY,100,1,0.5,daily,Instance2,sierra,papa
9
Account2,Subaccount4,ServiceZ,100,1,0.5,individually,Instance3,xray,papa
10
Account1,Subaccount2,ServiceY,100,1,0.5,daily,Instance2,zebra,alpha
11
Account1,Subaccount1,ServiceX,100,1,0.5,monthly,Instance,zebra,echo
Copied!
Last modified 24d ago
Export as PDF
Copy link