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 |  
                                    | jbbatts77Starting Member
 
 
                                        2 Posts | 
                                            
                                            |  Posted - 2013-03-08 : 14:57:56 
 |  
                                            | Hello,I have a table that has numerical data in it like so:333355556677778999How do I delete all records where only 2 or less instances exist?  In the above case it would be the two 6's and the 8 |  |  
                                    | Bustaz KoolMaster Smack Fu Yak Hacker
 
 
                                    1834 Posts | 
                                        
                                          |  Posted - 2013-03-08 : 19:33:13 
 |  
                                          | [CODE]delete MyTablewhere MyColumn in (   select MyColumn   from MyTable   group by MyColumn   having count(*) <= 2   )[/CODE]=================================================There are two kinds of light -- the glow that illuminates, and the glare that obscures. -James Thurber |  
                                          |  |  |  
                                    | visakh16Very Important crosS Applying yaK Herder
 
 
                                    52326 Posts | 
                                        
                                          |  Posted - 2013-03-09 : 00:58:37 
 |  
                                          | [code]delete tfrom(select cout(1) over (partition by yourcol) AS cntfrom table)twhere cnt<=2[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |  
                                          |  |  |  
                                |  |  |  |