SQL80. 打折
描述
prod_id | prod_price | sale_price |
a0011 | 9.49 | 8.541 |
a0019 | 600 | 540 |
b0019 | 1000 | 900 |
示例1
输入:
DROP TABLE IF EXISTS `Products`; CREATE TABLE IF NOT EXISTS `Products` ( `prod_id` VARCHAR(255) NOT NULL COMMENT '产品 ID', `prod_price` DOUBLE NOT NULL COMMENT '产品价格' ); INSERT INTO `Products` VALUES ('a0011',9.49), ('a0019',600), ('b0019',1000);
输出:
prod_id|prod_price|sale_price a0011|9.490|8.541 a0019|600.000|540.000 b0019|1000.000|900.000
Mysql 解法, 执行用时: 39ms, 内存消耗: 6412KB, 提交时间: 2022-03-04
select prod_id,prod_price,prod_price*0.9 as sale_price from Products
Mysql 解法, 执行用时: 39ms, 内存消耗: 6524KB, 提交时间: 2022-03-04
select prod_id,prod_price,round(prod_price*0.9,3) as sale_price from Products
Mysql 解法, 执行用时: 39ms, 内存消耗: 6536KB, 提交时间: 2022-03-04
select prod_id,prod_price ,round(prod_price*0.9,3 ) as sale_price from Products ;
Mysql 解法, 执行用时: 39ms, 内存消耗: 6600KB, 提交时间: 2022-03-04
SELECT prod_id,prod_price, (prod_price*0.9) AS sale_price FROM Products;
Mysql 解法, 执行用时: 39ms, 内存消耗: 6616KB, 提交时间: 2022-03-06
select *, 0.9*prod_price as sale_price from Products;