简体   繁体   English

如何在 sqldeveloper 中创建视图

[英]how can I create a view in sqldeveloper

I am trying to add this query in a view, while test it works fine and no syntax error but when click save, I get this error我试图在视图中添加这个查询,虽然测试它工作正常并且没有语法错误但是当点击保存时,我得到这个错误

ORA-00907: missing right parenthesis ORA-00907: 缺少右括号

This is the query:这是查询:

SELECT
    importer_id,
    AVG(count),
    STDDEV(count),
    AVG(count) + STDDEV(count) * 2 AS baseline
FROM
    (SELECT
         COUNT(declaration_identifier)        AS count,
         EXTRACT(MONTH FROM declaration_date) AS month,
         importer_id
     FROM
         declaration
     GROUP BY
         importer_id,
         EXTRACT(MONTH FROM declaration_date)
    )
GROUP BY
    importer_id

I created a dummy table to get your view to compile.我创建了一个虚拟表来编译您的视图。

create table declaration
( declaration_identifier integer,
  declaration_date date,
  importer_id integer
  );

I then wrapped your query with a CREATE VIEW...然后我用 CREATE VIEW 包装了您的查询...

CREATE VIEW SO_ERROR
AS SELECT
    imp_id as id,
    AVG(count) as count,
    STDDEV(count) as stddev,
    AVG(count) + STDDEV(count) * 2 as baseline
FROM
    (
        SELECT
            COUNT(declaration_identifier)         count,
            EXTRACT(MONTH FROM declaration_date)  month,
            importer_id imp_id
        FROM
            declaration
        GROUP BY
            importer_id,
            EXTRACT(MONTH FROM declaration_date) 
    )
GROUP BY
    imp_id;

Note that every column in the outer select has an ALIAS.请注意,外部 select 中的每一列都有一个别名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM