Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
evanburen
Posting Yak Master
167 Posts |
Posted - 2013-02-04 : 23:25:40
|
I have a list of BorrowerNumbers grouped by that field. I want to count the number of groups which don't have the TagName value of "dDirect" in it. So in this example with BorrowerNumber 1102469 I don't want to count this group because at least one record has dDirect in the TagName. I have many other groups with different BorrowerNumbers without dDirect and I want to identify these groups. Thanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-02-04 : 23:29:49
|
the below code will give you the borrownumber groups without dDirect tag in themSELECT *FROM(SELECT *,COUNT(CASE WHEN TagName = 'dDirect' THEN 1 ELSE NULL END) OVER (PARTITION BY BorrowNumber) AS DirectCntFROM Table)tWHERE DirectCnt=0 ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|