SQL: ORDER BY using a substring within a specific column… possible?

前端 未结 7 765
清酒与你
清酒与你 2020-11-30 12:02

I have a database whose columns are npID, title, URL, and issue.

Here is an example of two years\' entries:

npID               title               UR         


        
7条回答
  •  余生分开走
    2020-11-30 12:24

    Here's a variation of the same theme

    ORDER BY
        SUBSTRING(issue,1,4) Desc,
    
    CASE SUBSTRING(issue,6, LEN(issue) - 5)
       WHEN 'First_Quarter' THEN 1
       WHEN 'Second_Quarter' THEN 2
       WHEN 'Second_Quarter' THEN 3
       WHEN 'Winter' then 1
       WHEN 'Spring' then 2
       WHEN 'Summer' then 3
       WHEN 'Fall' then 4
    END
    

提交回复
热议问题