Forum Discussion

Tim Curwick's avatar
Tim Curwick
Copper Contributor
Sep 19, 2017
Solved

Get scalar value from table

Using the new OMS Log Analytics query language, how do I get a scalar value out of a table? That is, what is the equivalent of this TSQL query, presuming Table1 has a single row: Select @ScalarVar ...
  • Evgeny Ternovsky's avatar
    Evgeny Ternovsky
    Sep 20, 2017

    Tim,

     

    You're looking for toscalar(). For a slightly more advanced example of how to use it (together with makeset() and in()), check out the last section of our aggregations tutorial.

     

    To pseudocode your example, you'd be looking at something like:

    let myDateTime = toscalar(Table1 | summarize max(TimeGenerated)); 

    Table 2

    | where TimeGenerated between ((myDateTime - 5m) .. (myDateTime + 5m)) 

    | ...

Resources