表数据:https://www.cnblogs.com/zhishu/p/16452950.html
1.查询员工12个月的工资总和,并起别名为ANNUAL SALARY
别名中有空格的,要用双引号。
IFNULL(expr1,expr2),expr1如果不是null,返回expr1,否则返回expr2
SELECT employee_id , last_name,salary * 12 "ANNUAL SALARY"
FROM employees;
# 把奖金也算上
SELECT employee_id,last_name,salary * 12 * (1 + IFNULL(commission_pct,0)) "ANNUAL
SALARY"
FROM employees;
2.查询employees表中去除重复的job_id以后的数据
distinct关键字用于去重
SELECT DISTINCT job_id
FROM employees;
3.查询工资大于12000的员工姓名和工资
SELECT last_name, salary
FROM employees
WHERE salary > 12000;
4.查询员工号为176的员工的姓名和部门号
SELECT last_name, department_id
FROM employees
WHERE employee_id = 176;
5.显示表 departments 的结构,并查询其中的全部数据
DESC 关键字可以用来降序也可以用来显示表结构,
*
号表示所有数据
DESC departments;
SELECT * FROM departments;
标签:语句,salary,last,name,employees,MySQL,id,SELECT
From: https://www.cnblogs.com/zhishu/p/16798437.html