SELECT salary,department_id, CASE department_id WHEN 30 THEN salary*1.1
WHEN 40 THEN salary*1.2
WHEN 50 THEN salary*1.3
ELSE salary
END "now"
FROM employees ORDER BY department_id
SELECT salary ,
CASE
WHEN salary>20000 THEN ‘A‘
WHEN salary>15000 THEN ‘B‘
WHEN salary>10000 THEN ‘C‘
ELSE ‘D‘
END "de"
FROM employees
SELECT * FROM employees WHERE STR_TO_DATE(‘1992-4-3‘,‘%Y-%c-%d‘)=hiredate;
SELECT * FROM employees WHERE DATE_FORMAT(hiredate,‘%Y-%m-%d‘) =‘1992-04-03‘;
DATEDIFF参数为两个日期型
SELECT DATEDIFF(MAX(hiredate),MIN(hiredate)) FROM employees;
原文:https://www.cnblogs.com/liuchaobaidu/p/13491133.html