SQL Case Order By specific order

后端 未结 3 1851
广开言路
广开言路 2021-01-20 16:00

Ok, I asked something similar before, but I\'ve researched it and haven\'t found this specifically. I have a table that I need sorted on fields OptionName(NVarChar) and IsAc

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-20 16:32

    try,

    ORDER BY CASE WHEN PortalName = 'Company, Inc' THEN 0 
                  WHEN PortalName = 'Setup' THEN 1 
                  WHEN PortalName = 'Daily Routine' THEN 2 
                  WHEN IsActive = 1 THEN 3 
                  WHEN PortalName = 'Master Option' THEN 4 
             ELSE 5 END,
             PortalName ASC
    

提交回复
热议问题