Data sorting asc, desc 1. Single field sorting order by field name Function: Which field or fields to sort by Meaning: Sorting uses the order by clause, followed by the sorting field. You can put multiple sorting fields, separated by commas. Order by default uses ascending order (asc). If there is a where clause, then order by must be placed after the where clause. (1) Sort by salary from small to large (the system defaults to small to large) For example: (2) Get employees whose job is MANAGER and sort them by salary from small to large (the system defaults to small to large) For example:
(3) The following inquiry method is wrong: select * from emp order by sal whereselect * from emp order by sal where job = 'MANAGER'; 2. Manually specify field sorting (1) Manually specify the sorting by salary from small to large (ascending keyword asc) For example: (2) Manually specify the sorting by salary from high to low (descending keyword desc) For example: 3. Sorting multiple fields (1) Sort by job and salary in descending order For example: Note: If multiple fields are used for sorting, if the sorting based on the first field is repeated, the sorting will be based on the second field; 4. Sort by field position (1) Sort by salary in ascending order (this method is not recommended, as the meaning of the numbers is unclear, readability is poor, and the program is not robust) select * from emp order by 6; The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: JavaScript implements the nine-grid mobile puzzle game
>>: How to run a project with docker
1. mpstat command 1.1 Command Format mpstat [ -A ...
1. Preparation before installation: 1.1 Install J...
Recently, I have been working on thesis proposals ...
1. Introduction It has been supported since versi...
x-ua-compatible is used to specify the model for ...
First, let me introduce how to install PHP on Cen...
When I first used docker, I didn't use docker...
Table of contents 1. What is a hook? 2. Why does ...
Currently, almost all large websites and applicat...
Preface: In the previous article, we mainly intro...
Table of contents 1. Why do we need vue3? 2. Adva...
This article introduces an example of how to use ...
First post the effect picture: A scroll bar appear...
1. Introduction This article describes how to use...
The effect is as follows:Reference Program: <!...