Order against two columns at the same time (intersecting)

ぃ、小莉子 提交于 2019-12-04 18:34:15

Use a CASE statement to select the value for that row and ORDER BY that.

ORDER BY CommonName + FirstName, with appropriate ISNULL(<column>, '') if they are nullable.

ORDER BY
  CASE
    WHEN CommonName is null
    THEN FirstName
    ELSE CommonName
  END
order by coalesce(CommonName, FirstName)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!