1. Basic query statement
SELECT * FROM employees
#Query the name, department number and annual salary of the employee whose employee number is 176
SELECT last_name AS 姓名, department_id AS 部门, salary*12*(1+IFNULL(commission_pct,0)) AS 年薪 FROM employees WHERE employee_id = 176 select last_name , job_id , salary as sal from employees; select * from employees; SELECT employee_id, last_name, salary * 12 "ANNUAL SALARY" FROM employees; DESC employees SELECT DISTINCT job_id FROM employees SELECT CONCAT( employee_id, ',', job_id, ',', last_name, ',', IFNULL( commission_pct, 0 )) AS OUT_PUT FROM employees
#1. Query the name and salary of employees whose salary is greater than 12000
SELECT last_name AS NAME, salary FROM employees WHERE salary > 12000
#3. Select the name and salary of employees whose salary is not from 5000 to 12000
SELECT last_name, salary FROM employees WHERE salary NOT BETWEEN 5000 AND 12000
#4. Select the name and department number of the employee who works in department 20 or 50
SELECT last_name, employee_id FROM employees WHERE employee_id IN ( '20', '50') SELECT last_name, employee_id FROM employees WHERE employee_id = 20 OR employee_id = 50
#5. Select the name and job_id of the employee who has no manager in the company
SELECT last_name, job_id FROM employees WHERE manager_id IS NULL
#6. Select the name, salary and bonus level of employees who have bonuses in the company
SELECT last_name, salary, commission_pct FROM employees WHERE commission_pct IS NOT NULL
#7. Choose the employee name whose third letter is a
SELECT last_name FROM employees WHERE last_name LIKE '__a%'
#8. Select the names of employees with letters a and e in their names
SELECT last_name FROM employees WHERE last_name LIKE '%a%e%' or '%e%a%'
#9. Display the information of the employees whose first_name ends with'e' in the employees table
SELECT first_name FROM employees WHERE first_name LIKE '%e'
#10. Display the names and positions of the employees whose department number is between 80-100 in the table
SELECT last_name,department_id FROM employees WHERE employee_id between 80 AND 100
#11. Show that the manager_id of the table employees is 100,101,110 the name and position of the employee
SELECT last_name,department_id,manager_id FROM employees WHERE manager_id in ('100','101','110')
#1. Query the employee's name, department number and annual salary, in descending order of annual salary, in ascending order of name
SELECT last_name, department_id, salary * 12 *( IFNULL( 1+commission_pct, 0 )) AS 年薪 FROM employees ORDER BY 年薪 DESC, last_name ASC
#2. Select the names and salaries of employees whose salary is not between 8000 and 17000, in descending order of salary
SELECT last_name, salary FROM employees WHERE salary NOT BETWEEN 8000 AND 17000 ORDER BY salary DESC
#3. Query the employee information that contains e in the mailbox, first in descending order by the number of bytes in the mailbox, then in ascending order by department
SELECT * FROM employees WHERE email LIKE '%e%' ORDER BY LENGTH( email ) DESC, department_id ASC