"The aggregate expression '%1' must appear in either the select list or a HAVING clause subquery"
         
               
               
               
                  
                     | Item | 
                     Description | 
                  
               
               
                  
                     | 
                         SQLCode 
                      | 
                     
                         -862L 
                      | 
                  
                  
                     | 
                         Constant 
                      | 
                     
                         INVALID_AGGREGATE_PLACEMENT 
                      | 
                  
                  
                     | 
                         SQLState 
                      | 
                     
                         42W69 
                      | 
                  
                  
                     | 
                         ODBC 2 State 
                      | 
                     
                         37000 
                      | 
                  
                  
                     | 
                         ODBC 3 State 
                      | 
                     
                         42000 
                      | 
                  
                  
                     | 
                         Sybase Error Code 
                      | 
                     
                         2511 
                      | 
                  
                  
                     | 
                         Severity Code 
                      | 
                     
                         
                           15
                         
                      | 
                  
                  
                     | 
                         Parameter 1 
                      | 
                     
                         The aggregated expression in error.
 
                      | 
                  
               
            
 
         Probable cause
            
            An aggregated expression containing an outer reference must either appear in a select list expression (a subselect), or in a HAVING clause subquery in the query whose FROM clause contains the table with the column being aggregated.