当前位置:网站首页>SQL custom collation
SQL custom collation
2022-07-03 18:37:00 【"@ book mountain has a path%"】
SQL Custom collation
The original data

Result sequence data display
Apply: Submit a request
Review: Wait for a response
Finish: Task to complete
Sort by date and status , First status is : Submit a request (Apply)— In reverse chronological order , Then the status is : Wait for a response (Review)— In reverse chronological order , Then the status is : Task to complete (Finish)— In reverse chronological order .
Create table statement
DROP TABLE IF EXISTS `customsort`;
CREATE TABLE `customsort` ( `status` VARCHAR ( 255 ), `date1` date );
INSERT INTO `customsort` VALUES ('Review', '2022-01-11');
INSERT INTO `customsort` VALUES ('Apply', '2022-01-11');
INSERT INTO `customsort` VALUES ('Review', '2022-01-01');
INSERT INTO `customsort` VALUES ('Finish', '2022-01-14');
INSERT INTO `customsort` VALUES ('Apply', '2022-01-01');
INSERT INTO `customsort` VALUES ('Review', '2022-01-05');
Use case when Conditions then result ........ end
SELECT STATUS
,
date1,
( CASE WHEN STATUS = 'Apply' THEN 0 WHEN STATUS = 'Review' THEN 1 WHEN STATUS = 'Finish' THEN 2 ELSE 3 END ) type
FROM
customsort
to status Assign values with sort size type
Custom sort SQL
SELECT STATUS
,
date1
FROM
customsort
WHERE
STATUS IN ( 'Apply', 'Review', 'Finish' )
ORDER BY
( CASE WHEN STATUS = 'Apply' THEN 0 WHEN STATUS = 'Review' THEN 1 WHEN STATUS = 'Finish' THEN 3 ELSE 4 END ),
date1 DESC;

There are deficiencies , Please mention it in the comments !!!!!!!
边栏推荐
- Gao Qing, Beijing University of Aeronautics and Astronautics: CIM is a natural quantum computing platform for graph data processing
- Grammaire anglaise Nom - Classification
- How do microservices aggregate API documents? This wave of operation is too good
- After nohup NPM start &, close the shell window directly, and the process closes accordingly
- webcodecs
- How to disable the clear button of ie10 insert text box- How can I disable the clear button that IE10 inserts into textboxes?
- Computer graduation project PHP library book borrowing management system
- 2022-2028 global scar care product industry research and trend analysis report
- Caddy server agent
- Valentine's day, send you a little red flower~
猜你喜欢

Sensor debugging process

How to expand the capacity of golang slice slice

Bidding procurement scheme management of Oracle project management system
![[combinatorics] generating function (generating function application scenario | using generating function to solve recursive equation)](/img/e6/9880e708aed42dc82c94aea002020c.jpg)
[combinatorics] generating function (generating function application scenario | using generating function to solve recursive equation)

The vscode code is automatically modified to a compliance code when it is formatted and saved

Valentine's day, send you a little red flower~

Xception for deeplab v3+ (including super detailed code comments and original drawing of the paper)

What problems can cross-border e-commerce sellers solve with multi platform ERP management system

Mature port AI ceaspectus leads the world in the application of AI in terminals, CIMC Feitong advanced products go global, smart terminals, intelligent ports, intelligent terminals

Shell script return value with which output
随机推荐
What London Silver Trading software supports multiple languages
041. (2.10) talk about manpower outsourcing
How to analyze the rising and falling rules of London gold trend chart
[enumeration] annoying frogs always step on my rice fields: (who is the most hateful? (POJ hundred practice 2812)
shell 脚本中关于用户输入参数的处理
Bidding procurement scheme management of Oracle project management system
Self executing function
2022-2028 global physiotherapy clinic industry research and trend analysis report
php-fpm的max_chindren的一些误区
[combinatorics] exponential generating function (example 2 of solving multiple set permutation with exponential generating function)
22.2.14 -- station B login with code -for circular list form - 'no attribute' - 'needs to be in path selenium screenshot deviation -crop clipping error -bytesio(), etc
MySQL duplicate check
Nodejs (01) - introductory tutorial
Reappearance of ASPP (atlas spatial pyramid pooling) code
硬盘监控和分析工具:Smartctl
[combinatorics] generating function (property summary | important generating function)*
Naoqi robot summary 27
The vscode code is automatically modified to a compliance code when it is formatted and saved
How to disable the clear button of ie10 insert text box- How can I disable the clear button that IE10 inserts into textboxes?
How about the Moco model?