SELECT
ABS(-123),ABS(32),SIGN(-23),SIGN(43),PI(),CEIL(32.32),
CEILING(-43.23),FLOOR(32.32),
FLOOR(-43.23),MOD(12,5)
FROM DUAL;
SELECT RAND(),RAND(),RAND(10),RAND(10),RAND(-1),RAND(-1)
FROM DUAL;
SELECT
ROUND(12.33),ROUND(12.343,2),ROUND(12.324,-1),TRUNCATE(12.66,1),TRUNCATE(12.66,-1)
FROM DUAL;
SELECT ASCII('abc'),LENGTH('hello'),CHAR_LENGTH('我们')
LENGTH('hello'),LENGTH('我们')
FROM DUAL;
SELECT CONCAT (emp.last_name,'worked_for',mgr.last_name)
FROM employees emp JOIN employees mgr
WHERE emp.`manager_id`=mgr.`manager_id`;
SELECT NOW()
FROM DUAL;
SELECT last_name,salary ,IF(salary>=6000,'高工资','低工资')"details"
FROM employees;
SELECT last_name,commission_pct,IF(
commission_pct IS NOT NULL,commission_pct,0)"details",
FROM employees;
SELECT last_name,commission_pct,IFNULL(commission_pct,0)
FROM employees;
SELECT last_name,salary,CASE WHEN salary>=15000 THEN '白骨精'
WHEN salary>=10000 THEN '潜力股'
WHEN salary>=8000 THEN 'xiao'
ELSE '草根' END "details",department_id
FROM employees;
SELECT employee_id,last_name,department_id,salary,CASE department_id WHEN 10 THEN salary*1.1
WHEN 20 THEN salary*1.2
WHEN 30 THEN salary*1.3
ELSE salary*1.4 END "detaols"
FROM employees
WHERE department_id IN (10,20,30);
SELECT MD5('mysql'),SHA('PANG1234')
FROM DUAL;
SELECT BENCHMARK(9999999,MD5('MYSQL'))
FROM DUAL;
SELECT NOW()
FROM DUAL;
SELECT employee_id, last_name, salary, salary * 1.2 "new salary"
FROM employees;
SELECT last_name,LENGTH(last_name) "name_size"
FROM employees
ORDER BY name_size ASC;
SELECT CONCAT (employee_id,',',last_name,',',salary) "out_put"
FROM employees;
SELECT DATEDIFF(SYSDATE(), hire_date) / 365 worked_years, DATEDIFF(SYSDATE(),
hire_date) worked_days
FROM employees
ORDER BY worked_years DESC
SELECT last_name, hire_date, department_id
FROM employees
WHERE DATE_FORMAT(hire_date,'%Y') >= '1997'
AND department_id IN (80, 90, 110)
AND commission_pct IS NOT NULL
<last_name> earns <salary> monthly but wants <salary*3>
|