当前位置:网站首页>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 !!!!!!!
边栏推荐
- Lesson 13 of the Blue Bridge Cup -- tree array and line segment tree [exercise]
- What kind of experience is it when the Institute earns 20000 yuan a month?
- 2022-2028 global scar care product industry research and trend analysis report
- 4. Load balancing and dynamic static separation
- [combinatorics] generating function (use generating function to solve the combination number of multiple sets R)
- Data analysis is popular on the Internet, and the full version of "Introduction to data science" is free to download
- How many convolution methods does deep learning have? (including drawings)
- Analysis of the reasons why enterprises build their own software development teams to use software manpower outsourcing services at the same time
- Win 11 major updates, new features love love.
- Graduation summary
猜你喜欢

2022-2028 global marking ink industry research and trend analysis report

Caddy server agent

There are several levels of personal income tax

CV in transformer learning notes (continuously updated)

English语法_形容词/副词3级 - 倍数表达

How do microservices aggregate API documents? This wave of operation is too good

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

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

NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线

FBI 警告:有人利用 AI 换脸冒充他人身份进行远程面试
随机推荐
VLAN experiment
189. Rotation array
English grammar_ Adjective / adverb Level 3 - multiple expression
Read the paper glodyne global topology preserving dynamic network embedding
Sepconv (separable revolution) code recurrence
Unsafe类的使用
Niuke monthly race 31 minus integer
2022-2028 global physiotherapy clinic industry research and trend analysis report
虚拟机和开发板互Ping问题
Boost.Asio Library
[combinatorics] exponential generating function (example of exponential generating function solving multiple set arrangement)
[combinatorics] generating function (commutative property | derivative property | integral property)
Prototype inheritance..
[Yu Yue education] theoretical mechanics reference materials of Shanghai Jiaotong University
[combinatorics] exponential generating function (proving that the exponential generating function solves the arrangement of multiple sets)
Kratos微服务框架下实现CQRS架构模式
硬盘监控和分析工具:Smartctl
G1 garbage collector of garbage collector
Torch learning notes (2) -- 11 common operation modes of tensor
简述服务量化分析体系