当前位置:网站首页>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
!!!!!!!
边栏推荐
- 简述服务量化分析体系
- 平淡的生活里除了有扎破皮肤的刺,还有那些原本让你魂牵梦绕的诗与远方
- Three gradient descent methods and code implementation
- Unity webgl optimization
- Implementation of cqrs architecture mode under Kratos microservice framework
- Real time split network (continuous update)
- Opencv learning notes (continuously updated)
- Theoretical description of linear equations and summary of methods for solving linear equations by eigen
- Getting started with JDBC
- CV in transformer learning notes (continuously updated)
猜你喜欢
多媒体NFT聚合平台OKALEIDO即将上线,全新的NFT时代或将来临
How to draw non overlapping bubble chart in MATLAB
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
SQL injection -day16
Lesson 13 of the Blue Bridge Cup -- tree array and line segment tree [exercise]
Xception for deeplab v3+ (including super detailed code comments and original drawing of the paper)
How many convolution methods does deep learning have? (including drawings)
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
Kratos微服务框架下实现CQRS架构模式
[Godot] add menu button
随机推荐
Niuke monthly race 31 minus integer
How about the Moco model?
Win 11 major updates, new features love love.
What does foo mean in programming?
How to disable the clear button of ie10 insert text box- How can I disable the clear button that IE10 inserts into textboxes?
Getting started with JDBC
[untitled]
Grammaire anglaise Nom - Classification
Computer graduation design PHP makeup sales Beauty shopping mall
Reading a line from ifstream into a string variable
圖像24比特深度轉8比特深度
[combinatorics] exponential generating function (proving that the exponential generating function solves the arrangement of multiple sets)
199. Right view of binary tree - breadth search
Naoqi robot summary 27
Torch learning notes (4) -- torch's dynamic calculation diagram
How does GCN use large convolution instead of small convolution? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
Typescript official website tutorial
虚拟机和开发板互Ping问题
How to analyze the rising and falling rules of London gold trend chart
TypeScript 官网教程