搜索
简帛阁>技术文章>ORACEL条件表达式 CASE WHEN 和DECODE

ORACEL条件表达式 CASE WHEN 和DECODE

SELECT last_name, job_id, salary,
DECODE(job_id, 'IT_PROG', 1.10*salary,
'ST_CLERK', 1.15*salary,
'SA_REP', 1.20*salary,
salary)
REVISED_SALARY
FROM employees;

SELECT last_name, job_id, salary,
CASE job_id WHEN 'IT_PROG' THEN 1.10*salary
WHEN 'ST_CLERK' THEN 1.15*salary
WHEN 'SA_REP' THEN 1.20*salary
ELSE salary END "REVISED_SALARY"
FROM employees;

 

 

SELECTlast_name,job_id,salary,DECODE(job_id,'IT_PROG',110*salary,'ST_CLERK',115*salary,'SA_REP',120*
SELECTSTUDENT_NAME,(CASEWHENscore<60THEN'不及格'WHENscore>60ANDscore<80THEN'及格'WHENscore>80
百度百科:DECODE函数,是ORACLE公司的SQL软件ORACLEPL/SQL所提供的特有函数计算方式,以其简洁的运算方式,可控的数据模型灵活的格式转换而闻名。DECODE中的ifthenels
casewhen:参考:https://wwwcnblogscom/zqyanywn/p/5854079htmldecode参考:https://blogcsdnnet/sdut406/article
1问题对SQL排序,只要在orderby后面加字段就可以了,可以通过加desc或asc来选择降序或升序。但排序规则是默认的,数字、时间、字符串等都有自己默认的排序规则。有时候需要按自己的想法来排序,而
oracle中,我们要使用casewhen时,要怎样使用如下测试数据,我要把ClassId的1变成一班,2变成二班,3变成三班,那sql要怎样写呢?1、casewhen的用法oracle中casewh
SELECTlabel,label3,lon_cen,lat_cen,lon3,lat3,antenna_height,horizontal_angle,CASEWHENround(atan((ant
<prenamecodeclasssql>selectdatasid,datasname,datasmemo,to_char(datascreate_date,yyyymmddhh24:m
selectsubstr(key,13,2),casewhenbirthdaywhenbirthdaywhenbirthdaywhenbirthdaywhenbirthdaywhenbirthdaye
Case具有两种格式。简单Case函数Case搜索函数。简单Case函数CASEsexWHEN'1'THEN'男'WHEN'2'THEN'女'ELSE'其他'ENDCase搜索函数CASEWHENs