当前位置:网站首页>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 !!!!!!!
边栏推荐
- Raft 日志复制
- [combinatorics] exponential generating function (properties of exponential generating function | exponential generating function solving multiple set arrangement)
- 198. Looting - Dynamic Planning
- On Data Mining
- Analysis of the reasons why enterprises build their own software development teams to use software manpower outsourcing services at the same time
- 平淡的生活里除了有扎破皮肤的刺,还有那些原本让你魂牵梦绕的诗与远方
- Torch learning notes (7) -- take lenet as an example for dataload operation (detailed explanation + reserve knowledge supplement)
- SQL injection -day16
- [combinatorics] generating function (positive integer splitting | repeated ordered splitting | non repeated ordered splitting | proof of the number of repeated ordered splitting schemes)
- [combinatorics] generating function (commutative property | derivative property | integral property)
猜你喜欢

Computer graduation design PHP makeup sales Beauty shopping mall

Have you learned the correct expression posture of programmers on Valentine's day?

Analysis of the reasons why enterprises build their own software development teams to use software manpower outsourcing services at the same time

Opencv learning notes (continuously updated)

虚拟机和开发板互Ping问题

English语法_名词 - 分类

Three gradient descent methods and code implementation

What London Silver Trading software supports multiple languages

平淡的生活里除了有扎破皮肤的刺,还有那些原本让你魂牵梦绕的诗与远方

Theoretical description of linear equations and summary of methods for solving linear equations by eigen
随机推荐
CTO and programmer were both sentenced for losing control of the crawler
041. (2.10) talk about manpower outsourcing
Multifunctional web file manager filestash
TypeScript 官网教程
Software development freelancer's Road
How does GCN use large convolution instead of small convolution? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
What does foo mean in programming?
[combinatorics] exponential generating function (example 2 of solving multiple set permutation with exponential generating function)
Reappearance of ASPP (atlas spatial pyramid pooling) code
[combinatorics] generating function (positive integer splitting | repeated ordered splitting | non repeated ordered splitting | proof of the number of repeated ordered splitting schemes)
图像24位深度转8位深度
企业级自定义表单引擎解决方案(十二)--表单规则引擎2
Sensor 调试流程
Valentine's day, send you a little red flower~
What is the function of registering DLLs- What does registering a DLL do?
Computer graduation project PHP library book borrowing management system
Bidding procurement scheme management of Oracle project management system
[combinatorics] dislocation problem (recursive formula | general term formula | derivation process)*
2022-2028 global physiotherapy clinic industry research and trend analysis report
Torch learning notes (2) -- 11 common operation modes of tensor