SQL69. 返回产品并且按照价格排序
描述
prod_id | prod_name | prod_price |
a0011 | egg | 3 |
a0019 | sockets | 4 |
b0019 | coffee | 15 |
prod_name | prod_price |
egg | 3 |
sockets | 4 |
示例1
输入:
DROP TABLE IF EXISTS `Products`; CREATE TABLE IF NOT EXISTS `Products` ( `prod_id` VARCHAR(255) NOT NULL COMMENT '产品 ID', `prod_name` VARCHAR(255) NOT NULL COMMENT '产品名称', `prod_price` DOUBLE NOT NULL COMMENT '产品价格' ); INSERT INTO `Products` VALUES ('a0011','egg',3), ('a0019','sockets',4), ('b0019','coffee',15);
输出:
egg|3.000 sockets|4.000
Mysql 解法, 执行用时: 38ms, 内存消耗: 6500KB, 提交时间: 2022-03-03
select prod_name, prod_price from Products where prod_price >= 3 and prod_price <= 6 order by prod_price;
Mysql 解法, 执行用时: 39ms, 内存消耗: 6424KB, 提交时间: 2022-03-08
select prod_name,prod_price from Products where prod_price >= 3 and prod_price<=6 order by prod_price
Mysql 解法, 执行用时: 39ms, 内存消耗: 6436KB, 提交时间: 2022-03-07
select prod_name,prod_price from Products where prod_price between 3 and 6 order by prod_price
Mysql 解法, 执行用时: 39ms, 内存消耗: 6436KB, 提交时间: 2022-03-04
select prod_name, prod_price from Products where prod_price>= 3 and prod_price<=6;
Mysql 解法, 执行用时: 39ms, 内存消耗: 6460KB, 提交时间: 2022-03-07
select prod_name,prod_price from Products where prod_price between 3 and 6 order by prod_price asc;