共用方式為


is distinct 算子

適用於:勾選為「是」Databricks SQL 勾選為「是」Databricks Runtime

測試自變數是否有不同的值,其中 NUL 被視為可比較的值。

語法

expr1 is [not] distinct from expr2

引數

  • expr1:可比較類型的表達式。
  • expr2:與 共用最小公用型別的型別運算式,與 expr1

退貨

一個布爾值

如果 expr1expr2 都是 NULL,則會被視為不相異。

如果 只有其中 expr1 一個 且 expr2 為 NULL,則表示式會視為相異。

如果 expr1expr2 都不是 NULL,當 expr<>expr2 時會視為相異。

範例

> SELECT NULL is distinct from NULL;
 false

> SELECT NULL is distinct from 5;
 true

> SELECT 1 is distinct from 5;
 true

> SELECT NULL is not distinct from 5;
 false