SQL63. 检索顾客名称并且排序
描述
cust_id | cust_name |
a1 | andy |
a2 | ben |
a3 | tony |
a4 | tom |
a5 | an |
a6 | lee |
a7 | hex |
cust_name |
tony |
tom |
lee |
hex |
ben |
andy |
an |
示例1
输入:
DROP TABLE IF EXISTS `Customers`; CREATE TABLE IF NOT EXISTS `Customers`( cust_id VARCHAR(255) NOT NULL COMMENT '客户id', cust_name VARCHAR(255) NOT NULL COMMENT '客户姓名' ); INSERT `Customers` VALUES ('a1','andy'),('a2','ben'),('a3','tony'),('a4','tom'),('a5','an'),('a6','lee'),('a7','hex');
输出:
cust_name tony tom lee hex ben andy an
Mysql 解法, 执行用时: 39ms, 内存消耗: 6464KB, 提交时间: 2022-03-03
select cust_name from Customers group by cust_name order by cust_name desc;
Mysql 解法, 执行用时: 39ms, 内存消耗: 6488KB, 提交时间: 2022-03-07
select cust_name from Customers order by cust_name desc
Mysql 解法, 执行用时: 39ms, 内存消耗: 6500KB, 提交时间: 2022-03-03
SELECT cust_name FROM Customers ORDER BY cust_name DESC;
Mysql 解法, 执行用时: 39ms, 内存消耗: 6560KB, 提交时间: 2022-03-02
select cust_name from Customers order by cust_name desc
Mysql 解法, 执行用时: 39ms, 内存消耗: 6572KB, 提交时间: 2022-03-03
select cust_name from Customers order by 1 desc;