精心整理的SQL语句集锦,助力求职之路,祝您面试顺利!

SQL语句集锦

(以下仅为示例,请根据实际情况进行调整)

  • 基础查询

    • 查询所有员工信息: SELECT * FROM employees;
    • 查询姓名和部门的员工信息: SELECT name, department FROM employees;
    • 查询特定部门的员工: SELECT * FROM employees WHERE department = 'Sales';
  • 数据筛选

    • 查询薪资大于50000的员工: SELECT * FROM employees WHERE salary > 50000;
    • 查询姓名以'J'开头的员工: SELECT * FROM employees WHERE name LIKE 'J%';
    • 查询在2022年入职的员工: SELECT * FROM employees WHERE YEAR(hire_date) = 2022;
  • 数据排序

    • 按薪资降序排列员工信息: SELECT * FROM employees ORDER BY salary DESC;
    • 按部门升序,再按薪资降序排列员工信息: SELECT * FROM employees ORDER BY department ASC, salary DESC;
  • 聚合函数

    • 计算员工总数: SELECT COUNT(*) FROM employees;
    • 计算平均薪资: SELECT AVG(salary) FROM employees;
    • 查询每个部门的最高薪资: SELECT department, MAX(salary) FROM employees GROUP BY department;
  • 连接查询

    • 查询员工及其所在部门信息: SELECT e.name, d.department_name FROM employees e JOIN departments d ON e.department_id = d.department_id;
  • 子查询

    • 查询薪资高于平均薪资的员工: SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);
  • 数据修改

    • 将员工'John Doe'的薪资改为60000: UPDATE employees SET salary = 60000 WHERE name = 'John Doe';
    • 删除销售部门的所有员工: DELETE FROM employees WHERE department = 'Sales';

更多SQL语句示例,请参考相关资料或在线教程。

祝您求职顺利,找到理想工作!