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  | 
                             
                            
                                    | 
                                         lsy 
                                        Yak Posting Veteran 
                                         
                                        
                                        57 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2006-11-08 : 22:33:25
                                            
  | 
                                             
                                            
                                            | i have 2 table. One is the alarm list table and another is alarm table which keep track of when the alarm is happen.i would like to have a sql statement to join this 2 table for showing which alarm happen most frequent and the alarm description.Query column include [alarm id] and [alarm frequent] from alarm table and [alarm description] from alarm list table.my syntax is SELECT a.[alarm id], COUNT(a.[alarm id]), b.[alarm description]FROM alarm a, alarmlist bwhere [a.alarm id] = b.[alarm id]GROUP BY a.[alarm id]but this syntax is not working, it show 'alarm description' part of an aggregate function.Did anyone can help?? | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     snSQL 
                                    Master Smack Fu Yak Hacker 
                                     
                                    
                                    1837 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2006-11-08 : 23:21:57
                                          
  | 
                                         
                                        
                                          | [code]SELECT a.[alarm id], COUNT(a.[alarm id]), b.[alarm description]FROM alarm a, alarmlist bwhere [a.alarm id] = b.[alarm id]GROUP BY a.[alarm id], b.[alarm description][/code]  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     lsy 
                                    Yak Posting Veteran 
                                     
                                    
                                    57 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2006-11-08 : 23:44:50
                                          
  | 
                                         
                                        
                                          | thanks a lot...i got it... but why need to group the alarm description as well?  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |