[thelist] Understanding an SQL Problem

rudy r937 at interlog.com
Tue Jan 7 15:17:01 CST 2003


> Column 'IntranetLog.DateAccessed' is invalid in the select list because it
> is not contained in either an aggregate function or the GROUP BY clause.

well, that's pretty plain to me   ;o)

the GROUP BY clause must contain every column of the SELECT list that isn't
an aggregate function

so, for example, you could have

  select a, sum(b), x, avg(y) ...

but then you have to have

  group by a, x

so to fix your syntax error, you could say

    select DateAccessed
         , TimeAccessed
      from IntranetLog
     where DateAccessed = '1/6/03'
    group
        by DateAccessed
         , TimeAccessed
    order
        by TimeAccessed

but that wouldn't make much sense, because you aren't aggregating anything

i mean, there are cases where you need to group without taking some sort of
aggregate, but these are rare

what is it you are trying to do?

rudy




More information about the thelist mailing list