支持项目!网站的存在得益于社区。如果帮助覆盖费用,平台将保持免费。支持 →
SQL 代码已复制到剪贴板
任务 21:
销售部门希望向所有居住在 德克萨斯州 的客户发送新年祝福。编写一个 SQL 查询以检索这些客户的姓名和地址。
查询应输出一个包含两列的表:
姓名:一个由 TitleFirstNameMiddleNameLastName 以空格分隔的连接字符串。
地址:一个由 AddressLine1AddressLine2CityStateProvincePostalCode 以逗号分隔的连接字符串。
按客户的 LastName 排序结果。

在下面的字段中写下您的请求并点击 "检查它!" 按钮。

使用 SQL Server 2022 语法来写您的答案。 表的描述在屏幕底部提供。

获取提示 复制代码 清除编辑器

AdventureWorks 数据库:表结构和模式概述

AdventureWorks 数据库 (SQL Server) 是一个示例数据集,模拟了一个虚构制造公司的业务流程。

本页面展示了表结构、关键列和用于实际 SQL 学习和查询练习的关系。

AdventureWorks 数据库包含 10 个主要表。

AdventureWorks 数据库的 ER 图,显示表关系 AdventureWorks 数据库 ER 图

表列表

Address - 地址表。
  • AddressID每个地址的唯一标识符 (PK)
  • AddressLine1地址的第一行
  • AddressLine2地址的第二行
  • City城市
  • StateProvince州或省
  • CountryRegion国家
  • PostalCode邮政编码
  • rowguidguid
  • ModifiedDate行创建或最后更新的时间戳
  • 主键,btree (AddressID)
AddressID AddressLine1 AddressLine2 City StateProvince CountryRegion PostalCode rowguid ModifiedDate
9 8713 Yosemite Ct. null Bothell Washington United States 98011 268AF621-76D7-4C78-9441-144FD139821A 2006-07-01 00:00:00.000
Customer - 客户表。
  • CustomerID每个客户的唯一标识符 (PK)
  • NameStyle0 = FirstName 和 LastName 的数据以西方风格(名,姓)顺序存储。1 = 东方风格(姓,名)顺序。默认:0
  • Title称谓
  • FirstName名字
  • MiddleName中间名
  • LastName
  • Suffix后缀
  • CompanyName公司名称
  • SalesPerson销售人员
  • EmailAddress电子邮件
  • Phone电话号码
  • PasswordHash密码哈希
  • PasswordSalt
  • rowguidrowguid
  • ModifiedDate行创建或最后更新的时间戳
  • 主键,btree (CustomerID)
CustomerID NameStyle Title FirstName MiddleName LastName Suffix CompanyName SalesPerson EmailAddress Phone PasswordHash PasswordSalt rowguid ModifiedDate
1 0 先生 Orlando N. Gee [null] A Bike Store adventure-works\pamela0 orlando0@adventure-works.com 245-555-0173 L/Rlwxzp4w7RWmEgXX+/A7cXaePEPcp+KwQhl2fJL7w= 1KjXYs4= 3F5AE95E-B87D-4AED-95B4-C3797AFCB74F 2005-08-01 00:00:00.000
CustomerAddress - 客户与地址的关系。
  • CustomerID客户在 Customer 表中的标识符
  • AddressID地址在 Address 表中的标识符
  • AddressType地址类型
  • rowguidguid
  • ModifiedDate行创建或最后更新的时间戳
  • 主键,btree (CustomerID, AddressID)
  • 外键 (CustomerID) 参考 Customer(CustomerID)
  • 外键 (AddressID) 参考 Address(AddressID)
CustomerID AddressID AddressType rowguid ModifiedDate
29485 1086 主办公室 16765338-DBE4-4421-B5E9-3836B9278E63 2007-09-01 00:00:00.000
Product - 产品表。
  • ProductID每个产品的唯一标识符 (PK)
  • Name产品名称
  • ProductNumber商品编号
  • Color产品颜色
  • StandardCost产品价格
  • ListPrice产品在目录中的价格
  • Size产品尺寸
  • Weight产品重量
  • ProductCategoryID指向 ProductCategory 表的外键
  • ProductModelID指向 ProductModel 表的外键
  • SellStartDate销售开始日期的时间戳
  • SellEndDate销售结束日期的时间戳
  • DiscontinuedDate停止销售日期的时间戳
  • ThumbNailPhoto产品缩略图
  • ThumbnailPhotoFileName
    缩略图文件名
  • rowguidguid
  • ModifiedDate行创建或最后更新的时间戳
  • 主键,btree (ProductID, ProductCategoryID, ProductModelID)
  • 外键 (ProductCategoryID) 参考 ProductCategory(ProductCategoryID)
  • 外键 (ProductModelID) 参考 ProductModel(ProductModelID)
ProductID Name ProductNumber Color StandardCost ListPrice Size Weight ProductCategoryID ProductModelID SellStartDate SellEndDate DiscontinuedDate ThumbNailPhoto ThumbnailPhotoFileName rowguid ModifiedDate
680 HL Road Frame - Black, 58 FR-R92B-58 黑色 1059.3100 1431.5000 58 1016.04 18 6 2002-06-01 00:00:00.000 [null] [null] [binary] no_image_available_small.gif 43DD68D6-14A4-461F-9069-55309D90EA7E 2008-03-11 10:01:36.827
ProductCategory - 产品类别表。
  • ProductCategoryID每个产品类别的唯一标识符 (PK)
  • ParentProductCategoryID父产品类别的 ID
  • Name产品类别名称
  • rowguidguid
  • ModifiedDate行创建或最后更新的时间戳
  • 主键,btree (ProductCategoryID)
  • 外键 (ParentProductCategoryID) 参考 ProductCategory(ProductCategoryID)
ProductCategoryID ParentProductCategoryID Name rowguid ModifiedDate
1 [null] 自行车 CFBDA25C-DF71-47A7-B81B-64EE161AA37C 2002-06-01 00:00:00.000
ProductDescription - 产品描述表。
  • ProductDescriptionID记录的唯一 ID (PK)
  • Description产品描述
  • rowguidguid
  • ModifiedDate行创建或最后更新的时间戳