帮助ORA-00933错误

时间:2011-09-09 16:39:59

标签: oracle sqlplus

如果我将以下语句作为sql脚本的一部分运行

-- create the pivot_sales_data table
CREATE TABLE pivot_sales_data AS
  SELECT *
  FROM (
   SELECT month, prd_type_id, amount
   FROM all_sales
   WHERE year = 2003
   AND prd_type_id IN (1, 2, 3)
  )
  PIVOT (
   SUM(amount) FOR month IN (1 AS JAN, 2 AS FEB, 3 AS MAR, 4 AS APR)
  )
  ORDER BY prd_type_id;

我得到ORA-00933:SQL命令也没有正确结束错误。我在这里缺少什么?

1 个答案:

答案 0 :(得分:2)

你的支点不起作用。我特意想到:

FOR month IN (1 AS JAN, 2 AS FEB, 3 AS MAR, 4 AS APR)

In并不是真的那样。你要么:

FOR month IN ('JAN', 'FEB', 'MAR', 'APR')
-- or
FOR month IN (1,2,3,4)