New to SQL, function and cosmos db, sorry
I'm using Javascript, try to use some route parameter and query parameter from http trigger to retrieve data from cosmos db use its input binding.
In "sqlQuery" of cosmos db input binding, these route/query parameter can be refered with {key}. When I try to use {key} in SELECT clause, it resolved as string and cause some problem.
- I want use TOP n to filter, since the {max} is resolved as a string, I try to use CAST/CONVERT to conver to number, get different errors.
"sqlQuery": "SELECT TOP {max} * FROM c" Error: TOP need a number
"sqlQuery": "SELECT TOP CAST({max} AS int) * FROM c" Error: syntax near
- I want to select some properties within JSON, i figure out I should use c[{telemetry}], it does works, but the result are JSON with key name = "$1",
"sqlQuery": "SELECT TOP 10 c[{telemetry}] FROM c"
I get {$1: 25.3} and I expect something like {temperature: 25.3}
- If I use AS to convert, I get syntax error.
"sqlQuery": "SELECT TOP 10 c[{telemetry}] AS {telemetry} FROM c"