本文介绍了同时针对两列排序(相交)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表,其中包含字段 CommonName 和 FirstName .只有一个字段具有数据,而没有两个字段.有没有一种方法可以在SQL Server上以相交的方式对行进行排序?
I have a table with the fields CommonName and FirstName. Only either field has data, never both. Is there a way to order rows in an intersecting manner on SQL Server?
示例:
CommonName FirstName Bern Wade Ashley Boris Ayana我要按以下顺序排序记录:
I want records ordered like this:
CommonName FirstName Ashley Ayana Bern Boris Wade这可能吗?如果可以,怎么办?
Is this possible, and if so, how?
推荐答案ORDER BY CASE WHEN CommonName is null THEN FirstName ELSE CommonName END
更多推荐
同时针对两列排序(相交)
发布评论