我需要根据文档中可用的另一个字段的值来设置一个字段的值。
以下是我尝试获取要求的 SAQL。
WITH INPUT01 AS (
SELECT
input.id AS ID,
ROUND(input.sig,5) AS SIG,
input.dtcTriggeredDateTime.dateTime.time AS TIME,
input.Description as DESC
FROM [inputsignals] as input
WHERE GetArrayLength(input.abc) =0 AND (input.Description = 'xyz' OR input.Description = 'pqr')
SELECT
ID,
SIG,
TIME,
001 AS NUMID
INTO [cosmosDB]
FROM INPUT01
WHERE DESC = 'abc'
SELECT
ID,
SIG,
TIME,
002 AS NUMID
INTO [cosmosDB]
FROM INPUT01
WHERE DESC = 'pqr'
如果 DESC 是abc那么NUMID应该是001并且如果 DESC 是pqr那么NUMID应该是002。
除了单独编写最后两个选择语句之外,还有什么选项可以在单个 SELECT 查询中编写它,如下所示?
SELECT
ID,
SIG,
TIME,
001 AS NUMID (If DESC = abc)
002 AS NUMID (If DESC = pqr)
INTO [cosmosDB]
FROM INPUT01