帮助解决 ORA-00933 错误

发布于 2024-12-03 19:41:10 字数 423 浏览 1 评论 0原文

如果我将以下语句作为 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 Command 也没有正确结束的错误。我在这里缺少什么?

If I run the following statement as part of a sql script

-- 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;

I get the ORA-00933: SQL Command nor properly ended error. What am I missing here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小嗷兮 2024-12-10 19:41:10

你的枢轴实际上不起作用。我特别在想:

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)

Your pivot doesn't really work. I'm specifically thinking about:

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

In doesn't really work that way. You either want:

FOR month IN ('JAN', 'FEB', 'MAR', 'APR')
-- or
FOR month IN (1,2,3,4)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文