2

I have the following query:

customEvents
| summarize count(datepart("Second", timestamp) ) 
    by toint(customMeasurements.Latency)

This is counting the number of seconds past the minute and grouping it by an integer Latency.

How do I add an order by operator to this to order by these columns?

BanksySan
  • 27,362
  • 33
  • 117
  • 216
  • BTW, i'm not sure that your original query is doing what you intended it to do. count just counts the number of rows in the group so if you would have wrote "count(timestamp)" or event "count()" you would have gotten the exact same result. Did you mean to sum the number of seconds instead of count? – Asaf Strassberg Jul 03 '17 at 05:28

1 Answers1

2

In order to do this you need to alias the columns.

Aliasing columns is performed by prefixing the value with column_alias=.

customEvents
| summarize Count=count(datepart("Second", timestamp) ) 
    by Latency=toint(customMeasurements.Latency)

Then we can reference the columns by their aliases:

customEvents
| summarize Count=count(datepart("Second", timestamp) ) 
    by Latency=toint(customMeasurements.Latency)
| order by Latency asc nulls last 
BanksySan
  • 27,362
  • 33
  • 117
  • 216
  • 1
    Please note that you didn't have to set an alias to use the order operator. each column would have gotten a name even without setting an alias explicitly. in your case, the Latency column would have been called "customMeasurements_Latency" and you could have used the order operator on that name – Asaf Strassberg Jul 03 '17 at 05:32