SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 GROUP BY COUNT
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

evanburen
Posting Yak Master

158 Posts

Posted - 02/04/2013 :  23:25:40  Show Profile  Reply with Quote
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

India
52325 Posts

Posted - 02/04/2013 :  23:29:49  Show Profile  Reply with Quote
the below code will give you the borrownumber groups without dDirect tag in them

SELECT *
FROM
(
SELECT *,COUNT(CASE WHEN TagName = 'dDirect' THEN 1 ELSE NULL END) OVER (PARTITION BY BorrowNumber) AS DirectCnt
FROM Table
)t
WHERE DirectCnt=0


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000