|
所在平台: Udemy |
课程主页: https://www.udemy.com/course/sql-server-part1-basics-of-sql/
课程评论:没有评论
【Coursera 课程总结】SQL Server Part1 - SQL基础 本课程介绍了SQL Server数据库的基本概念和常用操作。 **1. SQL Server 安装与管理** * **SQL Server 安装**: 强调安装SQL Server Developer Edition或Express Edition,并进行基础配置(如选择身份验证模式)。 * **SSMS 安装与使用**: 介绍SQL Server Management Studio (SSMS) 的作用——可视化管理SQL Server数据库,包括创建、修改和执行SQL查询。 **2. SQL 查询基础** * **SELECT 语句**: 用于从表中检索数据。可指定列或使用 `*` 选择所有列。支持使用 `AS` 为列或表达式设置别名。 * **ORDER BY 子句**: 用于对查询结果进行排序,支持升序 (`ASC`,默认) 和降序 (`DESC`)。可按多个列排序。 * **WHERE 子句**: 用于根据指定条件过滤记录。支持多种运算符(`=, !=, <, >, BETWEEN, LIKE, IN, NOT IN`)以及逻辑运算符(`AND, OR, NOT`)组合条件。 **3. 数据分组与聚合** * **GROUP BY 子句**: 用于将具有相同值的行分组,通常与聚合函数一起使用,如 `COUNT()`, `SUM()`, `AVG()`。 * **HAVING 子句**: 用于过滤 `GROUP BY` 子句产生的聚合结果。与 `WHERE` 不同,`WHERE` 过滤单行,`HAVING` 过滤分组结果。 * **聚合函数**: 详细介绍了 `SUM()`, `AVG()`, `COUNT()`, `MIN()`, `MAX()` 等用于数据汇总的函数。 **4. 窗口函数 (OVER 子句)** * **OVER 子句与 Partition**: 介绍窗口函数,允许在不折叠行的前提下进行排名、计算运行总计等操作。
1. SQL Server InstallationSteps to install SQL Server:Download and install SQL Server Developer Edition or Express Edition from Microsoft.Configure SQL Server setup (choose authentication mode).Install SQL Server Management Studio (SSMS) to interact with the database.Connect to the SQL Server instance using SSMS. SSMS Installation (SQL Server Management Studio)SSMS is used to manage SQL Server databases visually.Download from Microsoft's website and install it.Use it to create, modify, and execute SQL queries easily.2. SELECT QueryUsed to retrieve data from one or more tables.Syntax: SELECT column1, column2 FROM table_name;Can retrieve all columns using SELECT * FROM table_name;Can use aliases with AS for better readability: SELECT column1 AS NewName FROM table_name;3. ORDER BY ClauseUsed to sort query results in ascending (ASC, default) or descending (DESC) order.Example: SELECT * FROM Employees ORDER BY Salary DESC;Can sort by multiple columns: ORDER BY Department ASC, Salary DESC;NULL values usually appear first in ascending order, last in descending.4. WHERE ClauseFilters records based on conditions.Operators: =,!=, , =, BETWEEN, LIKE, IN, NOT INExample: SELECT * FROM Employees WHERE Salary > 50000;Used with AND, OR, and NOT for multiple conditions.5. HAVING ClauseUsed to filter aggregated results from GROUP BY.Difference from WHERE: WHERE filters individual rows, HAVING filters grouped results.6. GROUP BY ClauseGroups rows sharing the same values into summary rows.Must be used with aggregate functions like COUNT(), SUM(), AVG().Example: SELECT Department, AVG(Salary) FROM Employees GROUP BY Department;7. Aggregation CalculationsFunctions used to summarize data:SUM(), AVG(), COUNT(), MIN(), MAX()8. OVER Clause with PartitionUsed for window functions to calculate rankings, running totals, etc., without collapsing rows.