我对这个sql视图有点麻烦。SQL查看帮助
CREATE OR REPLACE VIEW view_themed_booking AS
SELECT tb.*,
CASE
WHEN (tb.themed_party_size % 2) = 0 THEN
(tb.themed_party_size-2)/2
ELSE ((tb.themed_party_size-2)/2) + 0.5
END themed_tables
FROM themed_booking tb;
任何人都可以帮我吗?我试图在视图的末尾添加一列,(S-2)/2
的自然数结果,其中S
是themed_party_size
。
当我说自然数结果我的意思就像收集以.5结尾的答案,所以如果S=7
答案将是3
而不是2.5
。
我得到当我尝试运行上面的代码错误是
Error starting at line 1 in command:
CREATE OR REPLACE VIEW view_themed_booking AS
SELECT tb.*,
CASE WHEN (tb.themed_party_size % 2) = 0
THEN (tb.themed_party_size-2)/2
ELSE ((tb.themed_party_size-2)/2) + 0.5
END themed_tables
FROM themed_booking tb
Error at Command Line:3 Column:34
Error report:
SQL Error: ORA-00911: invalid character
00911. 00000 - "invalid character"
*Cause: identifiers may not start with any ASCII character other than
letters and numbers. $#_ are also allowed after the first
character. Identifiers enclosed by doublequotes may contain
any character other than a doublequote. Alternative quotes
(q'#...#') cannot use spaces, tabs, or carriage returns as
delimiters. For all other contexts, consult the SQL Language
Reference Manual.
*Action:
如果它的确与众不同,我使用的SQLDeveloper连接到Oracle服务器,所以我可以使用PL/SQL。
哈哈哦对不起忘了加上错误! – geekman92 2012-02-19 02:53:11