oracle case when using list of queries

Sql query statement is as follows

SELECT * FROM (
SELECT *
,ROW_NUMBER() OVER ( PARTITION BY scene_code ORDER BY (CASE status when 'DRAFT' then 3 when 'PRE' then 5 when 'GRAY' then 7 when 'PROD' then 9 END) DESC ) AS rank_id
FROM fus_recom_config
WHERE status in ('DRAFT','PRE','GRAY','PROD')
) a
WHERE a.rank_id=1
ORDER BY a.gmt_modified DESC
LIMIT 0,200

The query result is the same when scene_Code, will return to a state of highest data by status (PROD> GRAY> PRE> DRAFT), the same scene_Code pieces of data do not occur simultaneously

Guess you like

Origin www.cnblogs.com/panbingqi/p/10944665.html