目录
10-199 C2-1修改订单运费
分数 20
全屏浏览题目
切换布局
作者 柯海丰
单位 浙大城市学院
修改订单表(orders)
中的运费,将每单运费(Freight)
增加50%
提示:请使用UPDATE语句作答。
表结构:
orders
表:
列名 | 数据类型 | 长度 | 主码 | 说明 |
---|---|---|---|---|
OrderID | int | 11 | √ | 订单编号 |
CustomerID | varchar | 5 | 顾客编号 | |
EmployeeID | int | 11 | 员工编号 | |
OrderDate | datetime, | 订购日期 | ||
RequiredDate | datetime, | 预计到达日期 | ||
ShippedDate | datetime, | 发货日期 | ||
ShipVia | int | 11 | 运货商 | |
Freight | decimal | 10,4 | 运费 | |
ShipName | varchar | 40 | 货主姓名 | |
ShipAddress | varchar | 60 | 货主地址 | |
ShipCity | varchar | 15 | 所在城市 | |
ShipRegion | varchar | 15 | 区域 | |
ShipPostalCode | varchar | 10 | 邮政编码 | |
ShipCountry | varchar | 15 | 所在国家 |
表样例
orders
表:
OrderID | CustomerID | EmployeeID | OrderDate | RequiredDate | ShippedDate | ShipVia | Freight | ShipName | ShipAddress | ShipCity | ShipRegion | ShipPostalCode | ShipCountry |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
10248 | VINET | 5 | 1996/7/4 00:00:00 | 1996/8/1 00:00:00 | 1996/7/16 00:00:00 | 3 | 32.3800 | Vins et alcools Chevalier | 59 rue de l-Abbaye | Reims | 51100 | France | |
10249 | TOMSP | 6 | 1996/7/5 00:00:00 | 1996/8/16 00:00:00 | 1996/7/10 00:00:00 | 1 | 11.6100 | Toms Spezialitten | Luisenstr. 48 | Mnster | 44087 | Germany | |
10250 | HANAR | 4 | 1996/7/8 00:00:00 | 1996/8/5 00:00:00 | 1996/7/12 00:00:00 | 2 | 65.8300 | Hanari Carnes | Rua do Pao, 67 | Rio de Janeiro | RJ | 05454-876 | Brazil |
10251 | VICTE | 3 | 1996/7/8 00:00:00 | 1996/8/5 00:00:00 | 1996/7/15 00:00:00 | 1 | 41.3400 | Victuailles en stock | 2, rue du Commerce | Lyon | 69004 | France | |
10252 | SUPRD | 4 | 1996/7/9 00:00:00 | 1996/8/6 00:00:00 | 1996/7/11 00:00:00 | 2 | 51.3000 | Suprmes dlices | Boulevard Tirou, 255 | Charleroi | B-6000 | Belgium | |
10253 | HANAR | 3 | 1996/7/10 00:00:00 | 1996/7/24 00:00:00 | 1996/7/16 00:00:00 | 2 | 58.1700 | Hanari Carnes | Rua do Pao, 67 | Rio de Janeiro | RJ | 05454-876 | Brazil |
10254 | CHOPS | 5 | 1996/7/11 00:00:00 | 1996/8/8 00:00:00 | 1996/7/23 00:00:00 | 2 | 22.9800 | Chop-suey Chinese | Hauptstr. 31 | Bern | 3012 | Switzerland | |
10255 | RICSU | 9 | 1996/7/12 00:00:00 | 1996/8/9 00:00:00 | 1996/7/15 00:00:00 | 3 | 148.3300 | Richter Supermarkt | Starenweg 5 | Genve | 1204 | Switzerland | |
10256 | WELLI | 3 | 1996/7/15 00:00:00 | 1996/8/12 00:00:00 | 1996/7/17 00:00:00 | 2 | 13.9700 | Wellington Importadora | Rua do Mercado, 12 | Resende | SP | 08737-363 | Brazil |
10257 | HILAA | 4 | 1996/7/16 00:00:00 | 1996/8/13 00:00:00 | 1996/7/22 00:00:00 | 3 | 81.9100 | HILARION-Abastos | Carrera 22 con Ave. Carlos Soublette #8-35 | San Cristbal | Tchira | 5022 | Venezuela |
输出样例:
OrderID | CustomerID | EmployeeID | OrderDate | RequiredDate | ShippedDate | ShipVia | Freight | ShipName | ShipAddress | ShipCity | ShipRegion | ShipPostalCode | ShipCountry |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
10248 | VINET | 5 | 1996-07-04 00:00:00 | 1996-08-01 00:00:00 | 1996-07-16 00:00:00 | 3 | 48.57 | Vins et alcools Chevalier | 59 rue de l-Abbaye | Reims | 51100 | France | |
10249 | TOMSP | 6 | 1996-07-05 00:00:00 | 1996-08-16 00:00:00 | 1996-07-10 00:00:00 | 1 | 17.415 | Toms Spezialitten | Luisenstr. 48 | Mnster | 44087 | Germany | |
10250 | HANAR | 4 | 1996-07-08 00:00:00 | 1996-08-05 00:00:00 | 1996-07-12 00:00:00 | 2 | 98.745 | Hanari Carnes | Rua do Pao, 67 | Rio de Janeiro | RJ | 05454-876 | Brazil |
10251 | VICTE | 3 | 1996-07-08 00:00:00 | 1996-08-05 00:00:00 | 1996-07-15 00:00:00 | 1 | 62.01 | Victuailles en stock | 2, rue du Commerce | Lyon | 69004 | France | |
10252 | SUPRD | 4 | 1996-07-09 00:00:00 | 1996-08-06 00:00:00 | 1996-07-11 00:00:00 | 2 | 76.95 | Suprmes dlices | Boulevard Tirou, 255 | Charleroi | B-6000 | Belgium | |
10253 | HANAR | 3 | 1996-07-10 00:00:00 | 1996-07-24 00:00:00 | 1996-07-16 00:00:00 | 2 | 87.255 | Hanari Carnes | Rua do Pao, 67 | Rio de Janeiro | RJ | 05454-876 | Brazil |
10254 | CHOPS | 5 | 1996-07-11 00:00:00 | 1996-08-08 00:00:00 | 1996-07-23 00:00:00 | 2 | 34.47 | Chop-suey Chinese | Hauptstr. 31 | Bern | 3012 | Switzerland | |
10255 | RICSU | 9 | 1996-07-12 00:00:00 | 1996-08-09 00:00:00 | 1996-07-15 00:00:00 | 3 | 222.495 | Richter Supermarkt | Starenweg 5 | Genve | 1204 | Switzerland | |
10256 | WELLI | 3 | 1996-07-15 00:00:00 | 1996-08-12 00:00:00 | 1996-07-17 00:00:00 | 2 | 20.955 | Wellington Importadora | Rua do Mercado, 12 | Resende | SP | 08737-363 | Brazil |
10257 | HILAA | 4 | 1996-07-16 00:00:00 | 1996-08-13 00:00:00 | 1996-07-22 00:00:00 | 3 | 122.865 | HILARION-Abastos | Carrera 22 con Ave. Carlos Soublette #8-35 | San Cristbal | Tchira | 5022 | Venezuela |
UPDATE
orders
SET
Freight = Freight * 1.5;
10-200 C2-2修改特定职工的订单运费
分数 20
全屏浏览题目
切换布局
作者 柯海丰
单位 浙大城市学院
修改订单表(orders)
中员工编号(EmployeeID)
为3
和4
的员工的订单,将每单运费(Freight)
减少5%
提示:请使用UPDATE语句作答。
表结构:
orders
表:
列名 | 数据类型 | 长度 | 主码 | 说明 |
---|---|---|---|---|
OrderID | int | 11 | √ | 订单编号 |
CustomerID | varchar | 5 | 顾客编号 | |
EmployeeID | int | 11 | 员工编号 | |
OrderDate | datetime, | 订购日期 | ||
RequiredDate | datetime, | 预计到达日期 | ||
ShippedDate | datetime, | 发货日期 | ||
ShipVia | int | 11 | 运货商 | |
Freight | decimal | 10,4 | 运费 | |
ShipName | varchar | 40 | 货主姓名 | |
ShipAddress | varchar | 60 | 货主地址 | |
ShipCity | varchar | 15 | 所在城市 | |
ShipRegion | varchar | 15 | 区域 | |
ShipPostalCode | varchar | 10 | 邮政编码 | |
ShipCountry | varchar | 15 | 所在国家 |
表样例
orders
表:
OrderID | CustomerID | EmployeeID | OrderDate | RequiredDate | ShippedDate | ShipVia | Freight | ShipName | ShipAddress | ShipCity | ShipRegion | ShipPostalCode | ShipCountry |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
10248 | VINET | 5 | 1996/7/4 00:00:00 | 1996/8/1 00:00:00 | 1996/7/16 00:00:00 | 3 | 32.3800 | Vins et alcools Chevalier | 59 rue de l-Abbaye | Reims | 51100 | France | |
10249 | TOMSP | 6 | 1996/7/5 00:00:00 | 1996/8/16 00:00:00 | 1996/7/10 00:00:00 | 1 | 11.6100 | Toms Spezialitten | Luisenstr. 48 | Mnster | 44087 | Germany | |
10250 | HANAR | 4 | 1996/7/8 00:00:00 | 1996/8/5 00:00:00 | 1996/7/12 00:00:00 | 2 | 65.8300 | Hanari Carnes | Rua do Pao, 67 | Rio de Janeiro | RJ | 05454-876 | Brazil |
10251 | VICTE | 3 | 1996/7/8 00:00:00 | 1996/8/5 00:00:00 | 1996/7/15 00:00:00 | 1 | 41.3400 | Victuailles en stock | 2, rue du Commerce | Lyon | 69004 | France | |
10252 | SUPRD | 4 | 1996/7/9 00:00:00 | 1996/8/6 00:00:00 | 1996/7/11 00:00:00 | 2 | 51.3000 | Suprmes dlices | Boulevard Tirou, 255 | Charleroi | B-6000 | Belgium | |
10253 | HANAR | 3 | 1996/7/10 00:00:00 | 1996/7/24 00:00:00 | 1996/7/16 00:00:00 | 2 | 58.1700 | Hanari Carnes | Rua do Pao, 67 | Rio de Janeiro | RJ | 05454-876 | Brazil |
10254 | CHOPS | 5 | 1996/7/11 00:00:00 | 1996/8/8 00:00:00 | 1996/7/23 00:00:00 | 2 | 22.9800 | Chop-suey Chinese | Hauptstr. 31 | Bern | 3012 | Switzerland | |
10255 | RICSU | 9 | 1996/7/12 00:00:00 | 1996/8/9 00:00:00 | 1996/7/15 00:00:00 | 3 | 148.3300 | Richter Supermarkt | Starenweg 5 | Genve | 1204 | Switzerland | |
10256 | WELLI | 3 | 1996/7/15 00:00:00 | 1996/8/12 00:00:00 | 1996/7/17 00:00:00 | 2 | 13.9700 | Wellington Importadora | Rua do Mercado, 12 | Resende | SP | 08737-363 | Brazil |
10257 | HILAA | 4 | 1996/7/16 00:00:00 | 1996/8/13 00:00:00 | 1996/7/22 00:00:00 | 3 | 81.9100 | HILARION-Abastos | Carrera 22 con Ave. Carlos Soublette #8-35 | San Cristbal | Tchira | 5022 | Venezuela |
输出样例:
OrderID | CustomerID | EmployeeID | OrderDate | RequiredDate | ShippedDate | ShipVia | Freight | ShipName | ShipAddress | ShipCity | ShipRegion | ShipPostalCode | ShipCountry |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
10248 | VINET | 5 | 1996/7/4 00:00:00 | 1996/8/1 00:00:00 | 1996/7/16 00:00:00 | 3 | 32.3800 | Vins et alcools Chevalier | 59 rue de l-Abbaye | Reims | 51100 | France | |
10249 | TOMSP | 6 | 1996/7/5 00:00:00 | 1996/8/16 00:00:00 | 1996/7/10 00:00:00 | 1 | 11.6100 | Toms Spezialitten | Luisenstr. 48 | Mnster | 44087 | Germany | |
10250 | HANAR | 4 | 1996-07-08 00:00:00 | 1996-08-05 00:00:00 | 1996-07-12 00:00:00 | 2 | 62.5385 | Hanari Carnes | Rua do Pao, 67 | Rio de Janeiro | RJ | 05454-876 | Brazil |
10251 | VICTE | 3 | 1996-07-08 00:00:00 | 1996-08-05 00:00:00 | 1996-07-15 00:00:00 | 1 | 39.273 | Victuailles en stock | 2, rue du Commerce | Lyon | 69004 | France | |
10252 | SUPRD | 4 | 1996-07-09 00:00:00 | 1996-08-06 00:00:00 | 1996-07-11 00:00:00 | 2 | 48.735 | Suprmes dlices | Boulevard Tirou, 255 | Charleroi | B-6000 | Belgium | |
10253 | HANAR | 3 | 1996-07-10 00:00:00 | 1996-07-24 00:00:00 | 1996-07-16 00:00:00 | 2 | 55.2615 | Hanari Carnes | Rua do Pao, 67 | Rio de Janeiro | RJ | 05454-876 | Brazil |
10254 | CHOPS | 5 | 1996/7/11 00:00:00 | 1996/8/8 00:00:00 | 1996/7/23 00:00:00 | 2 | 22.9800 | Chop-suey Chinese | Hauptstr. 31 | Bern | 3012 | Switzerland | |
10255 | RICSU | 9 | 1996/7/12 00:00:00 | 1996/8/9 00:00:00 | 1996/7/15 00:00:00 | 3 | 148.3300 | Richter Supermarkt | Starenweg 5 | Genve | 1204 | Switzerland | |
10256 | WELLI | 3 | 1996-07-15 00:00:00 | 1996-08-12 00:00:00 | 1996-07-17 00:00:00 | 2 | 13.2715 | Wellington Importadora | Rua do Mercado, 12 | Resende | SP | 08737-363 | Brazil |
10257 | HILAA | 4 | 1996-07-16 00:00:00 | 1996-08-13 00:00:00 | 1996-07-22 00:00:00 | 3 | 77.8145 | HILARION-Abastos | Carrera 22 con Ave. Carlos Soublette #8-35 | San Cristbal | Tchira | 5022 | Venezuela |
UPDATE
orders
SET
Freight = Freight * 0.95
WHERE
EmployeeID = 3 OR EmployeeID = 4;
10-201 C2-3根据运费调整订单单价
分数 20
全屏浏览题目
切换布局
作者 柯海丰
单位 浙大城市学院
对于运费(Freight)
超过30.00
的订单,将其相关的订单详情表(orderdetails)
中产品的单价(UnitPrice)
提高15%
提示:请使用UPDATE语句作答。
表结构:
orderdetails
表:
列名 | 数据类型 | 长度 | 主码 | 说明 |
---|---|---|---|---|
OrderID | int | 11 | √ | 订单编号 |
ProductID | int | 11 | √ | 产品编号 |
UnitPrice | decimal | 10,4 | 单位价格 | |
Quantity | smallint | 2 | 数量 | |
Discount | double | 8,0 | 折扣 |
orders
表:
列名 | 数据类型 | 长度 | 主码 | 说明 |
---|---|---|---|---|
OrderID | int | 11 | √ | 订单编号 |
CustomerID | varchar | 5 | 顾客编号 | |
EmployeeID | int | 11 | 员工编号 | |
OrderDate | datetime, | 订购日期 | ||
RequiredDate | datetime, | 预计到达日期 | ||
ShippedDate | datetime, | 发货日期 | ||
ShipVia | int | 11 | 运货商 | |
Freight | decimal | 10,4 | 运费 | |
ShipName | varchar | 40 | 货主姓名 | |
ShipAddress | varchar | 60 | 货主地址 | |
ShipCity | varchar | 15 | 所在城市 | |
ShipRegion | varchar | 15 | 区域 | |
ShipPostalCode | varchar | 10 | 邮政编码 | |
ShipCountry | varchar | 15 | 所在国家 |
表样例
orderdetails
表:
OrderID | ProductID | UnitPrice | Quantity | Discount |
---|---|---|---|---|
10248 | 11 | 14.0000 | 12 | 0 |
10248 | 42 | 9.8000 | 10 | 0 |
10248 | 72 | 34.8000 | 5 | 0 |
10249 | 14 | 18.6000 | 9 | 0 |
10249 | 51 | 42.4000 | 40 | 0 |
10250 | 41 | 7.7000 | 10 | 0 |
10250 | 51 | 42.4000 | 35 | 0 |
10250 | 65 | 16.8000 | 15 | 0 |
10251 | 22 | 16.8000 | 6 | 0 |
10251 | 57 | 15.6000 | 15 | 0 |
orders
表:
OrderID | CustomerID | EmployeeID | OrderDate | RequiredDate | ShippedDate | ShipVia | Freight | ShipName | ShipAddress | ShipCity | ShipRegion | ShipPostalCode | ShipCountry |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
10248 | VINET | 5 | 1996/7/4 00:00:00 | 1996/8/1 00:00:00 | 1996/7/16 00:00:00 | 3 | 32.3800 | Vins et alcools Chevalier | 59 rue de l-Abbaye | Reims | 51100 | France | |
10249 | TOMSP | 6 | 1996/7/5 00:00:00 | 1996/8/16 00:00:00 | 1996/7/10 00:00:00 | 1 | 11.6100 | Toms Spezialitten | Luisenstr. 48 | Mnster | 44087 | Germany | |
10250 | HANAR | 4 | 1996/7/8 00:00:00 | 1996/8/5 00:00:00 | 1996/7/12 00:00:00 | 2 | 65.8300 | Hanari Carnes | Rua do Pao, 67 | Rio de Janeiro | RJ | 05454-876 | Brazil |
10251 | VICTE | 3 | 1996/7/8 00:00:00 | 1996/8/5 00:00:00 | 1996/7/15 00:00:00 | 1 | 41.3400 | Victuailles en stock | 2, rue du Commerce | Lyon | 69004 | France | |
10252 | SUPRD | 4 | 1996/7/9 00:00:00 | 1996/8/6 00:00:00 | 1996/7/11 00:00:00 | 2 | 51.3000 | Suprmes dlices | Boulevard Tirou, 255 | Charleroi | B-6000 | Belgium | |
10253 | HANAR | 3 | 1996/7/10 00:00:00 | 1996/7/24 00:00:00 | 1996/7/16 00:00:00 | 2 | 58.1700 | Hanari Carnes | Rua do Pao, 67 | Rio de Janeiro | RJ | 05454-876 | Brazil |
10254 | CHOPS | 5 | 1996/7/11 00:00:00 | 1996/8/8 00:00:00 | 1996/7/23 00:00:00 | 2 | 22.9800 | Chop-suey Chinese | Hauptstr. 31 | Bern | 3012 | Switzerland | |
10255 | RICSU | 9 | 1996/7/12 00:00:00 | 1996/8/9 00:00:00 | 1996/7/15 00:00:00 | 3 | 148.3300 | Richter Supermarkt | Starenweg 5 | Genve | 1204 | Switzerland | |
10256 | WELLI | 3 | 1996/7/15 00:00:00 | 1996/8/12 00:00:00 | 1996/7/17 00:00:00 | 2 | 13.9700 | Wellington Importadora | Rua do Mercado, 12 | Resende | SP | 08737-363 | Brazil |
10257 | HILAA | 4 | 1996/7/16 00:00:00 | 1996/8/13 00:00:00 | 1996/7/22 00:00:00 | 3 | 81.9100 | HILARION-Abastos | Carrera 22 con Ave. Carlos Soublette #8-35 | San Cristbal | Tchira | 5022 | Venezuela |
输出样例:
OrderID | ProductID | UnitPrice | Quantity | Discount |
---|---|---|---|---|
10248 | 11 | 16.1000 | 12 | 0 |
10248 | 42 | 11.2700 | 10 | 0 |
10248 | 72 | 40.0200 | 5 | 0 |
10249 | 14 | 18.6000 | 9 | 0 |
10249 | 51 | 42.4000 | 40 | 0 |
10250 | 41 | 8.8550 | 10 | 0 |
10250 | 51 | 48.7600 | 35 | 0 |
10250 | 65 | 19.3200 | 15 | 0 |
10251 | 22 | 19.3200 | 6 | 0 |
10251 | 57 | 17.9400 | 15 | 0 |
UPDATE
orderdetails
SET
UnitPrice = UnitPrice * 1.15
WHERE
OrderID in(
SELECT
OrderID
FROM
orders
WHERE
Freight>30
)