Microsoft OLE DB Provider for ODBC Drivers error ''80040e14''

  •  I'm trying to use the group by clause as i want to see the data according to the country  group. My coding is as follows:

    Select p.*, i.RequiredDataName, Co.CountryName, Ci.CitiName from Pmfindicators p, " & _

       " IndicatorData i, Country Co, Cities Ci where p.IndicatorNo = i.DataNumber and " & _

       " p.City = Ci.CitiId and p.Country = Co.CountryId group by p.Country"

     But i received this error.

    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

    [Microsoft][ODBC SQL Server Driver][SQL Server]Column 'p.IdNo' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

    How can i correct this? Please help me. Thanks.

     

  • From Books Online

    "When GROUP BY is specified, either each column in any non-aggregate expression in the select list should be included in the GROUP BY list, or the GROUP BY expression must match exactly the select list expression."

     

    --------------------
    Colt 45 - the original point and click interface

  • Are you trying to sort the results by p.Country? 

    If so, use ORDER BY p.Country instead of GROUP BY, which is used with aggregate functions ( like SUM(), COUNT(), etc. ) in the SELECT list.

     

     

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply