case col when val1 then ... when val2 then ... else ... endselect id , sum(case col when val1 then ... else ... end) , sum(case col when val2 then ... else ... end)
/--给个例句:select No, Firstname, case when Age > 40 then 40 else 30 end from table_test;
case col when val1 then ... when val2 then ... else ... end select id , sum(case col when val1 then ... else ... end) , sum(case col when val2 then ... else ... end) from tb group by id
好像都有问题吧plsql里应该要加 上casecase when 条件1 then statement1; when 条件2 then statement2; when 条件3 then statement3; when 条件4 then statement4; else statement5; end case;
case when 条件1 then statement1; when 条件2 then statement2; when 条件3 then statement3; when 条件4 then statement4; else statement5; end case好像都有问题吧plsql里一定要加 上end case;
呵呵,昨天还发帖说到这个问题.sql 里是: case ... end proc 是: case ... end case;proc里end后要再加个case的
/--给个例句:select No,
Firstname,
case
when Age > 40 then
40
else
30
end
from table_test;
select id , sum(case col when val1 then ... else ... end) , sum(case col when val2 then ... else ... end) from tb group by id
when 条件1 then statement1;
when 条件2 then statement2;
when 条件3 then statement3;
when 条件4 then statement4;
else statement5;
end case;
case
when 条件1 then statement1;
when 条件2 then statement2;
when 条件3 then statement3;
when 条件4 then statement4;
else statement5;
end case好像都有问题吧plsql里一定要加 上end case;
proc 是: case ... end case;proc里end后要再加个case的