SQL Server 数据库总结

2026/4/27 20:01:30

s '班级' ,

address as '地址' , phone as '联系方式', Grade.gradeName as '年级'

from Grade left join Student on Student.gradeId = Grade.id --右连接查询 select

Student.id as '学号' , name as '姓名' , age as '年龄' , gradeId as '班级' ,

address as '地址' , phone as '联系方式', Grade.gradeName as '年级'

from Student RIGHT join Grade on Student.gradeId = Grade.id

--FULL连接查询 select

Student.id as '学号' , name as '姓名' , age as '年龄' , gradeId as '班级' ,

address as '地址' , phone as '联系方式', Grade.gradeName as '

年级' from Student FULL JOIN Grade on Student.gradeId = Grade.id --内连接查询 select Student.id as '学号' , name as '姓名' , age as '年龄' , gradeId as '班级' , address as '地址' , phone as '联系方式', Grade.gradeName as '年级' from Student inner join Grade on Student.gradeId = Grade.id

UNION 查询

UNION 操作符用于合并两个或多个 SELECT 语句的结果集。

请注意,UNION 内部的 SELECT 语句必须拥有相同数量的列。列也必须拥有相似的数据类型。同时,每条 SELECT 语句中的列的顺序必须相同。

--UNION 查询,联合查询 select 1,2,3,4,5 from Student union select 1,2,3,4,5 from Grade select name , age ,sex from Student union select null , null , null from Grade order by 1

SQL 聚合函数

聚合函数对一组值执行计算,并返回单个值。除了 COUNT 以外,聚合函数都会忽略空值。聚合函数经常与 SELECT 语句的 GROUP BY 子句一起使用。

聚合函数只能在以下位置作为表达式使用:

1、SELECT 语句的选择列表(子查询或外部查询)。 2、COMPUTE 或 COMPUTE BY 子句。 3、HAVING 子句。 年龄

datediff(yy,出生日期,getdate())

AVG 平均数 MIN 最小值 SUM 总数 COUNT 统计个数 MAX 最大值

分组:

select 类别, sum(数量) as 数量之和 from A group by 类别


SQL Server 数据库总结.doc 将本文的Word文档下载到电脑
搜索更多关于: SQL Server 数据库总结 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219