【问题标题】:Nested condition for Azure Stream analyticsAzure 流分析的嵌套条件
【发布时间】:2018-11-02 08:05:37
【问题描述】:

我有两个问题:

  1. Azure 流分析是否支持使用 CASE 语句的嵌套条件?
  2. 我看到这里提到的 CASE 表达式有两种格式-https://docs.microsoft.com/en-us/stream-analytics-query/case-azure-stream-analytics。我找到了搜索案例here 的示例。任何人都可以举个简单 CASE 表达式的例子吗?

【问题讨论】:

    标签: azure azure-stream-analytics stream-analytics


    【解决方案1】:

    样本数据:

    [{
    "id": "0001",
    "type": "donut",
    "name": "Cake"
    },
    {
    "id": "0002",
    "type": "donut2",
    "name": "Cake2"
    ]
    

    Azure 流分析是否支持使用 CASE 的嵌套条件 声明?

    根据我的测试,它支持嵌套的 case 条件。

    SQL:

    select jsoninput.id as id, jsoninput.type as type ,
    case when 
        ((case when  jsoninput.id = '0001' then '0' else '1' end) = '0' ) then '0'
    else  '1' end as res
    from jsoninput
    

    输出:

    谁能举个简单 CASE 表达式的例子?

    SQL:

    select jsoninput.id as id, jsoninput.type as type ,
    case jsoninput.id when '0001' then 'true' else 'false' end as res 
    from jsoninput
    

    输出:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-23
      • 2019-09-26
      • 1970-01-01
      相关资源
      最近更新 更多