2

我有一个如下所示的 Oracle 选择:

SELECT *
  FROM CUSTOMER
 WHERE (CUSTOMER_TYPE BETWEEN 100 AND 200
     OR CUSTOMER_TYPE = 350
     OR CUSTOMER_TYPE BETWEEN 410 AND 520);

我想将其更改为在同一语句中结合多个范围和单个值的评估的东西。以下语法不正确,但是否有一些 Oracle 等价物?

SELECT *
  FROM CUSTOMER
 WHERE CUSTOMER_TYPE IN (100..200, 350, 410..520);
4

1 回答 1

0

考虑这是一种可能性。

SELECT *
FROM CUSTOMER c,
(
    select level + 99 n from dual connect by level < 102
        union all
    select 350 n from dual
        union all
    select level + 409 n from dual connect by level < 112
) t
WHERE c.CUSTOMER_TYPE = t.n

它避免了ORIN。如果你幸运的话,一个哈希连接就是结果。

于 2012-08-09T20:41:15.867 回答