我在SQL server 2012上工作。我面临无法从表gen中获取行的问题
当它仅在基于zplid和codetypeid的zfeaturekey字段上的所有行上为Null时。
这意味着我需要在zfeaturekey上的所有行上获取只有NULL的行
create table #gen
(
CodeTypeId int,
Zplid int,
Zfeaturekey nvarchar(50)
)
insert into #gen values
(854838,25820,NULL),
(849774,25820,NULL),
(849774,25820,NULL),
(849774,25820,NULL),
(849774,25820,NULL),
(987431,26777,NULL),
(987431,26777,1502280005),
(987431,26777,1502290001)
CodeTypeId Zplid Zfeaturekey
854838 25820 NULL
849774 25820 NULL
849774 25820 NULL
849774 25820 NULL
849774 25820 NULL
Result I need:
CodeTypeId Zplid COUNT
854838 25820 1
849774 25820 4
我不会使用zplid26777,因为它在另一行上有Null和值1502280005
所以我需要通过zplid和codetypeid来选择feature在所有行上为NULL的位置。