SQL-basics

SQL 一些常用的查询语句用法


SQL 中的聚合函数

SQL 中的子查询

SQL 使用实例

SELECT F_NAME , L_NAME

FROM EMPLOYEES

WHERE ADDRESS LIKE '%Elgin,IL%';

SELECT F_NAME , L_NAME

FROM EMPLOYEES

WHERE B_DATE LIKE '197%';

SELECT *

FROM EMPLOYEES

WHERE (SALARY BETWEEN 60000 AND 70000) AND DEP_ID = 5;

SELECT F_NAME, L_NAME, DEP_ID

FROM EMPLOYEES

ORDER BY DEP_ID;

SELECT F_NAME, L_NAME, DEP_ID

FROM EMPLOYEES

ORDER BY DEP_ID DESC, L_NAME DESC;

SELECT D.DEP_NAME , E.F_NAME, E.L_NAME

FROM EMPLOYEES as E, DEPARTMENTS as D

WHERE E.DEP_ID = D.DEPT_ID_DEP

ORDER BY D.DEP_NAME, E.L_NAME DESC;

SELECT DEP_ID, COUNT(*)

FROM EMPLOYEES

GROUP BY DEP_ID;

SELECT DEP_ID, COUNT(*), AVG(SALARY)

FROM EMPLOYEES

GROUP BY DEP_ID;

SELECT DEP_ID, COUNT(*) AS "NUM_EMPLOYEES", AVG(SALARY) AS "AVG_SALARY"

FROM EMPLOYEES

GROUP BY DEP_ID;

SELECT DEP_ID, COUNT(*) AS "NUM_EMPLOYEES", AVG(SALARY) AS "AVG_SALARY"

FROM EMPLOYEES

GROUP BY DEP_ID

ORDER BY AVG_SALARY;

SELECT DEP_ID, COUNT() AS "NUM_EMPLOYEES", AVG(SALARY) AS "AVG_SALARY"
FROM EMPLOYEES
GROUP BY DEP_ID
HAVING count(
) < 4

ORDER BY AVG_SALARY;

相关推荐
h***06657 分钟前
【JSqlParser】Java使用JSqlParser解析SQL语句总结
java·开发语言·sql
华纳云IDC服务商2 小时前
MySQL数据库如何防止SQL注入攻击
数据库·sql·mysql
合作小小程序员小小店2 小时前
桌面开发,在线%物品代送,代接管理%系统,基于vs2022,c#,winform,sql server数据。
开发语言·数据库·sql·microsoft·c#
j***82703 小时前
Mybatis控制台打印SQL执行信息(执行方法、执行SQL、执行时间)
数据库·sql·mybatis
8***f3953 小时前
SQL中的REGEXP正则表达式使用指南
数据库·sql·正则表达式
M***Z2103 小时前
【SQL技术】不同数据库引擎 SQL 优化方案剖析
数据库·sql
5***r9354 小时前
SQL实现md5加密方法
数据库·sql
i***77804 小时前
mysql 迁移达梦数据库出现的 sql 语法问题 以及迁移方案
数据库·sql·mysql
t***82114 小时前
【Oracle11g SQL详解】日期和时间函数:SYSDATE、TO_DATE、TO_CHAR 等
数据库·sql