ahmed elbarbary

ahmed elbarbary

  • NA
  • 1.6k
  • 278k

How to get zplid that have two code type one code type have Null on zf

Dec 13 2020 9:52 AM
How to get zplid that have two code type one code type have Null on zfeature key and another have value only without null ?
I work on sql server 2012 . I face issue I can't get zplid from table #gen that have Null only zfeature key on code type and another have value only
on zfeaturekey based on zplid and codetypeid .
meaning I need to get rows that have NULL ON zfeaturekey and Values on Zfeaturekey but must be different code type but same zplid
 
 
  1. create table #gen  
  2.         (  
  3.         CodeTypeId int,  
  4.         Zplid  int,  
  5.         Zfeaturekey nvarchar(50)  
  6.         )  
  7.         insert into #gen values  
  8. (854838,25820,NULL),  
  9. (849774,25820,1502260001),  
  10. (849774,25820,1502260016),  
  11.   
  12. (854890,28700,NULL),  
  13. (849780,28700,1502260013),  
  14. (849780,28700,1502260030),  
  15.   
  16. (987431,26777,1502270003),  
  17. (987431,26777,1502280005),  
  18. (987431,26777,1502290001),  
  19.   
  20. (987471,26720,NULL),  
  21. (987490,26720,1502280005),  
  22. (987490,26720,NULL)  
  23.   
  24. xpcted Result :  
  25.   
  26. CodeTypeId    Zplid    Zfeaturekey  
  27. 854838    25820    NULL  
  28. 849774    25820    1502260001  
  29. 849774    25820    1502260016  
  30. 854890    28700    NULL  
  31. 849780    28700    1502260013  
  32. 849780    28700    1502260030  
result will be zplid 25820 and 28700 because it have more than on code type code type 854890 and have null on zfeature key
 
and code type 849774 and not have null only value
 
i will not get zplid 26777 because it Not have NULL ON zfeaturekey
 
i will not get zplid 26720 because it have NULL ON BOTH Code Type ON zfeaturekey
 

Answers (1)