首页 > 解决方案 > 具有空行的 SQL Server 中的 CASE

问题描述

SQL Server 和堆栈中的新功能。这是我的第一个问题,如果有问题请帮我纠正

我希望能够共享整个查询,因为它太大但下面是我的最终输出

personno personcat answervale personno personcat answervale 
-----------------------------------------------------------
12         1          yes        null     null     null
12         2          no          12      1        test
null       null       null        12      2        check

但我想安排这个最终输出

 personcat personno answervale personcat personno answervale
 ------------------------------------------------------------
  1         12     yes           1        12         test

 personcat personno answervale personcat personno answervale
  2       12     no           2        12         check

如上所述,我只需要两行,但我得到所有答案的行

我尝试过的事情:

  1. 基于personcat的案例

  2. 我在 where 使用 union added personcat 但仍然没有得到预期的输出

如果有人可以提出其他方法来获得预期的输出 - 请帮助

提前致谢。

标签: sqlsql-server

解决方案


推荐阅读