是否可以在Teradata中使用带有where-in子句的表达式列表

时间:2015-08-06 17:10:38

标签: oracle teradata

Here are the Oracle docs for what I'm trying to do。是Teradata中可能的第三个例子吗?

我创建了一个显示我问题的SQL fiddle。我只想选择Corvette第7代和Mustang第1代车辆的订单。这在oracle中工作正常,但是当我尝试从Teradata会话执行它时,它失败了

  

SELECT失败。 3707:语法错误,预期类似'SELECT'   关键字或'('或'NONTEMPORAL'关键字或'AS'关键字'('   和整数'120777'。

SQL Fiddle

Oracle 11g R2架构设置

OneClassSVM

查询1

CREATE TABLE CAR_ORDERS
(
    ORD_ID INTEGER NOT NULL,
    MODEL_NAME VARCHAR2(20) NOT NULL,
    GENERATION INTEGER NOT NULL,
    BEGIN_YEAR INTEGER NOT NULL,
    END_YEAR INTEGER NOT NULL
 );


INSERT INTO CAR_ORDERS VALUES(1,  'CORVETTE', 1, 1953, 1962);
INSERT INTO CAR_ORDERS VALUES(2,  'CORVETTE', 1, 1953, 1962);
INSERT INTO CAR_ORDERS VALUES(3,  'CORVETTE', 1, 1953, 1962);
INSERT INTO CAR_ORDERS VALUES(4,  'CORVETTE', 1, 1953, 1962);
INSERT INTO CAR_ORDERS VALUES(5,  'CORVETTE', 2, 1963, 1967);
INSERT INTO CAR_ORDERS VALUES(6,  'CORVETTE', 3, 1968, 1982);
INSERT INTO CAR_ORDERS VALUES(7,  'CORVETTE', 4, 1984, 1996);
INSERT INTO CAR_ORDERS VALUES(8,  'CORVETTE', 5, 1997, 2004);
INSERT INTO CAR_ORDERS VALUES(9,  'CORVETTE', 6, 2005, 2013);
INSERT INTO CAR_ORDERS VALUES(10, 'CORVETTE', 6, 2005, 2013);
INSERT INTO CAR_ORDERS VALUES(11, 'CORVETTE', 7, 2014, 2016);
INSERT INTO CAR_ORDERS VALUES(12, 'CORVETTE', 7, 2014, 2016);
INSERT INTO CAR_ORDERS VALUES(13, 'CORVETTE', 7, 2014, 2016);
INSERT INTO CAR_ORDERS VALUES(14, 'CORVETTE', 7, 2014, 2016);
INSERT INTO CAR_ORDERS VALUES(15, 'MUSTANG', 1, 1964, 1973);

Results

SELECT *
  FROM CAR_ORDERS CO
 WHERE (CO.MODEL_NAME, CO.GENERATION) IN (('CORVETTE', 7), ('MUSTANG', 1))

1 个答案:

答案 0 :(得分:0)

您可以在TERADATA中执行以下操作:

CREATE TABLE CAR_ORDERS
AS SELECT * FROM TABLE_NAME 
WHERE   
(MODEL_NAME='CORVETTE' and GENERATION=7) 
OR  
(MODEL_NAME='MUSTANG' and GENERATION=1)
WITH DATA;

如果这样做很好,如果没有,那么先尝试创建表,然后使用INSERT QUERY:

INSERT INTO CAR_ORDERS
SELECT * FROM TABLE_NAME 
WHERE   
(MODEL_NAME='CORVETTE' and GENERATION=7) 
OR  
(MODEL_NAME='MUSTANG' and GENERATION=1);