Adventureworks是一个示例数据库,可以用来学习和练习SQL Server。以下是一些常见的练习:
SELECT * FROM Sales.SalesOrderHeader;
SELECT * FROM Production.Product ORDER BY Name ASC;
SELECT TOP 1 COALESCE(p.FirstName + ' ', '') + p.LastName AS FullName, SUM(soh.SubTotal) AS TotalSales FROM Sales.SalesOrderHeader AS soh INNER JOIN Sales.SalesPerson AS sp ON soh.SalesPersonID = sp.BusinessEntityID INNER JOIN Person.Person AS p ON sp.BusinessEntityID = p.BusinessEntityID WHERE YEAR(soh.OrderDate) = 2003 GROUP BY p.FirstName, p.LastName ORDER BY TotalSales DESC;
SELECT Name, ListPrice FROM Production.Product;
通过这些练习,您可以学习一些基本的SQL Server查询,以及如何使用Adventureworks数据库。