当前位置:网站首页>排序查询
排序查询
2022-06-26 04:28:00 【莉莉妖_】
排序查询:SELECT 查询列表 FROM 表 WHERE 筛选条件 ORDER BY 排序列表(ASC/DESC)AEC
/DESC
= 升序/降序,默认为升序ORDER BY
支持单个字段
、多个字段
、表达式
、函数
、别名
按单个字段排序
#1. 查询员工信息,要求工资从高到低排序
SELECT *
FROM employees
ORDER BY salary DESC
#2. 查询部门编号大于等于90的员工信息,按入职时间的先后进行排序
SELECT *
FROM employees
WHERE department_id >= 90
ORDER BY hiredate ASC
按表达式 / 别名排序
#3. 按照年薪的高低显示员工的信息和年薪【按表达式排序】
SELECT *,salary*12*(1+IFNULL(commission_pct,0)) AS "年薪"
FROM employees
ORDER BY "年薪" DESC
按函数排序
#4. 按照姓名的长度显示员工的姓名和工资【按函数排序】
SELECT LENGTH(last_name) AS "字节长度",last_name,salary
FROM employees
ORDER BY LENGTH(last_name) DESC
按多个字段排序
#5. 查询员工信息,要求先按工资升序,再按员工编号降序【按多个字段排序】
SELECT *
FROM employees
ORDER BY salary ASC,employee_id DESC
边栏推荐
- Ueeditor automatically appends P tags to rich text.br tags always wrap.br tag solutions
- Laravel uses phpword to generate word documents
- 1064 (42000) error occurred when installing MySQL and modifying root password
- C generic
- Notes on enterprise wechat development [original]
- redis集群的方式
- Create alicloud test instances
- pip 批量完全卸载包
- Report on the "fourteenth five year plan" and future development direction of global and Chinese indoor vertical farms from 2022 to 2028
- Thinkphp6 using kindeditor
猜你喜欢
Read / write lock for thread synchronization
[geek challenge 2019] rce me
PHP design function getmaxstr to find the longest symmetric string in a string - [original]
There is no response to redirection and jump in the laravel constructor [original]
Capture packets (Wireshark)
Thinkphp6 using kindeditor
Computer network high frequency interview questions
ctf [RoarCTF 2019]easy_ calc
6、 Project practice --- identifying cats and dogs
Construction of art NFT trading platform | NFT mall
随机推荐
MySQL est livré avec l'outil de test de performance MySQL lap pour effectuer des tests de résistance
Read / write lock for thread synchronization
Sorting out the examination sites of the 13th Blue Bridge Cup single chip microcomputer objective questions
VHDL design
2020-12-18
Your requirements could not be resolved
Redis cache data consistency solution analysis
Parse JSON interface and insert it into the database in batch
PHP small factory moves bricks for three years - interview series - my programming life
Review of number theory
Minecraft 1.16.5 生化8 模组 1.9版本 1.18版本同步
企业的产品服务怎么进行口碑营销?口碑营销可以找人代做吗?
Create alicloud test instances
Modify the number of Oracle connections
College C language final exam · multiple choice questions · summary notes of mistakes and difficulties
List of provinces, cities and counties in China
Gateway can not connect to tcp://127.0.0.1: Connection refused
ctf [RoarCTF 2019]easy_ calc
Tp6 is easy to tread [original]
Video label forbids downloading. The test is valid. Hide button. The test is valid at three points