2017-07-02 31 views
0

我有以下查詢:應用洞察按訂單合計

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

這是計數過去一分鐘的秒數,並通過一個整數Latency分組它。

如何添加一個order by運算符到這個按這些列排序?

+0

BTW,我不知道你的原始查詢是做什麼的,你打算做的事。 count只是計算組中的行數,所以如果你會寫「count(timestamp)」或事件「count()」,你會得到完全相同的結果。你的意思是總結秒數而不是數? –

回答

0

爲了做到這一點,你需要別名的列。

別名列是通過在值前加上column_alias=來執行的。

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

然後,我們可以通過它們的別名引用列:

customEvents 
| summarize Count=count(datepart("Second", timestamp)) 
    by Latency=toint(customMeasurements.Latency) 
| order by Latency asc nulls last 
+0

請注意,您不必設置別名即可使用訂單運算符。即使沒有明確設置別名,每列也會得到一個名稱。在你的情況下,延遲列將被稱爲「customMeasurements_Latency」,你可以使用該名稱的順序操作符 –