标签:mysq lse rtm dep style comm 工资 div span
#if函数(条件,返回值1,返回值2) SELECT IF(10>5,‘大‘,‘小‘) SELECT last_name,commission_pct,IF(commission_pct IS NULL,‘不存在‘,‘有‘) 别名 from employee; #case函数 (等值) 1.case +要判断的变量或表达式 when 常量1+then+要输出的信息1; when 常量2+then+要输出的信息2; ... else 要显示的值; end /* 部门号=30,1.1倍工资 部门号=40,1.2倍工资 部门号=50,1.3倍工资 其他,原工资 */ SELECT salary 原始工资,department_id, CASE department_id WHEN 30 THEN salary*1.1 WHEN 40 THEN salary*1.2 WHEN 50 THEN SELECT*1.3 ELSE salary END AS新工资 FROM employee; (区间) 2. /* 如果工资>20000,显示A 如果工资>15000,显示B 如果工资>10000,显示C 否则,显示D */ SELECT salary CASE WHEN salary>20000 THEN ‘A‘ WHEN salary>15000 THEN ‘B‘ WHEN salary>10000 THEN ‘C‘ ELSE D END AS 工资级别 FROM employee;
标签:mysq lse rtm dep style comm 工资 div span
原文地址:https://www.cnblogs.com/god-for-speed/p/10893459.html