-1到100并显示'Fizz'如果数字可以被3'Buzz'整除,如果可以被5整除,'FizzBuzz'可以被两者整除。下面是我的代码
select
Case when Remainder (rownum,3)=0 then 'Fizz'
when Remainder (rownum,5)=0 then 'Buzz'
when (remainder (rownum,3)=0 and remainder(ROWNUM,5) = 0) then 'FizzBuzz'
else rownum end
from DUAL
Connect by level <=100;
它给了我错误 - ORA-00932:数据类型不一致:预期CHAR得到NUMBER
00932. 00000 - “不一致的数据类型:预期%s获得%s”
*原因:
*行动:
行错误:5列:18
答案 0 :(得分:2)
这是在你的声明中。 Rownum是一个数字,而Fizz,Buzz和FizzBuzz是CHAR。
答案 1 :(得分:0)
SELECT ... from attr_laptop ...
或
select
Case when Remainder (rownum,3)=0 then 'Fizz'
when Remainder (rownum,5)=0 then 'Buzz'
when (remainder (rownum,3)=0 and remainder(ROWNUM,5) = 0) then 'FizzBuzz'
else ''||rownum end
from DUAL
Connect by level <=100;