第一范文网 - 专业文章范例文档资料分享平台

SQL Server 数据库总结

来源:用户分享 时间:2025/5/16 2:30:37 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

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 数据库总结 的文档
SQL Server 数据库总结.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c0j9i55fged1qw0a8dn6z_7.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top