3.6.9
Search…
⌃K

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:
account,account2,service,quantity,rate,cogs,interval,instance,ref1,ref2
Account1,Subaccount1,ServiceX,100,1,0.5,monthly,Instance,zebra,echo
Account1,Subaccount2,ServiceY,100,1,0.5,daily,Instance2,delta,echo
Account1,Subaccount2,ServiceY,100,1,0.5,daily,Instance2,zebra,alpha
Account1,Subaccount2,ServiceY,100,1,0.5,daily,Instance2,delta,echo
Account1,Subaccount3,ServiceZ,100,1,0.5,individually,Instance3,charlie,zebra
Account1,Subaccount3,ServiceZ,100,1,0.5,individually,Instance3,charlie,bravo
Account1,Subaccount3,ServiceZ,100,1,0.5,individually,Instance3,charlie,romeo
Account2,Subaccount4,ServiceX,100,1,0.5,monthly,Instance,golf,tango
Account2,Subaccount4,ServiceY,100,1,0.5,daily,Instance2,sierra,papa
Account2,Subaccount4,ServiceZ,100,1,0.5,individually,Instance3,xray,papa
... the following statement:
sort example.sort by ref1 ref2
... will reorder the usage records as follows.
account,account2,service,quantity,rate,cogs,interval,instance,ref1,ref2
Account1,Subaccount3,ServiceZ,100,1,0.5,individually,Instance3,charlie,bravo
Account1,Subaccount3,ServiceZ,100,1,0.5,individually,Instance3,charlie,romeo
Account1,Subaccount3,ServiceZ,100,1,0.5,individually,Instance3,charlie,zebra
Account1,Subaccount2,ServiceY,100,1,0.5,daily,Instance2,delta,echo
Account1,Subaccount2,ServiceY,100,1,0.5,daily,Instance2,delta,echo
Account2,Subaccount4,ServiceX,100,1,0.5,monthly,Instance,golf,tango
Account2,Subaccount4,ServiceY,100,1,0.5,daily,Instance2,sierra,papa
Account2,Subaccount4,ServiceZ,100,1,0.5,individually,Instance3,xray,papa
Account1,Subaccount2,ServiceY,100,1,0.5,daily,Instance2,zebra,alpha
Account1,Subaccount1,ServiceX,100,1,0.5,monthly,Instance,zebra,echo
Last modified 5mo ago