回覆列表
  • 1 # lanfengz3

    1, deocde 與 case when 的作用相同,用於不同條件分支的不同處理。於case when 相比只是用法不同。同樣可以巢狀和滿足多個值。

    2,多個值

    decode(name, "Wang", "001", "Li", "002", "003")

    相當於

    case

    when name = "Wang"

    then "001"

    when name = "Li"

    then "002"

    else "003"

    end

    3, 巢狀

    decode(name, "Wang", decode(sno, "001", "Yes", ""), "Li", decode(sno,"002","Yes",""), decode(sno, "003","Yes",""))

    相當於

    case

    when name = "Wang"

    then case

    when sno="001"

    then "Yes"

    else ""

    end

    when name="Li"

    then case

    when sno="002"

    then "Yes"

    else ""

    end

    else case

    when sno="003"

    then "Yes"

    else ""

    end

    end

  • 中秋節和大豐收的關聯?
  • 崖山之後再無大宋,假如宋金夏聯合抗蒙,歷史會怎樣改寫?