Elxis CMS Forum

Support => Database => Topic started by: forgetms on November 10, 2010, 04:17:49

Title: Error with 2009.2 and PostgreSQL
Post by: forgetms on November 10, 2010, 04:17:49
URI: index2.php
Message: ERROR: column "session.username" must appear in the GROUP BY clause or be used in an aggregate function LINE 1: SELECT username, time, userid, usertype, gid, ip FROM sessio... ^
SELECT username, time, userid, usertype, gid, ip FROM session GROUP BY ip ORDER BY time DESC LIMIT 10 OFFSET 0

Regards,

CN
Title: Re: Error with 2009.2 and PostgreSQL
Post by: CREATIVE Options on November 10, 2010, 08:59:40
Hello, this is not an Elxis problem but from ADODB.
for how to solve this, first seach the forum for the solution, we have already answer it.

And then if you dont find it, post back please.
Title: Re: Error with 2009.2 and PostgreSQL
Post by: forgetms on November 10, 2010, 11:15:25
Thank you for the reply!

I have not successfully found the post you mentioned.

I have few knowledge about Elxis/ADODB/SQL standards. However, I am still attaching the following excerpt from PostgreSQL discussion archive as follows if you are interested in the so called "SQL standards":

"The simple fact is that it is only in the 1992 standard that it states that
ALL columns in the SELECT clause must be identified in the GROUP BY clause.
In all subsequent standards it has been permissible to omit any column from
the GROUP BY clause if it is functionally dependent on any other column in
the GROUP BY clause."

http://archives.postgresql.org/pgsql-bugs/2008-10/msg00061.php (http://archives.postgresql.org/pgsql-bugs/2008-10/msg00061.php)

Best Regards,

CN

[begin add]
http://www.ianywhere.com/developer/product_manuals/sqlanywhere/0902/en/html/dbugen9/00000284.htm (http://www.ianywhere.com/developer/product_manuals/sqlanywhere/0902/en/html/dbugen9/00000284.htm)

"The SQL/92 standard for GROUP BY requires the following:

A column used in an expression of the SELECT clause must be in the GROUP BY clause. Otherwise, the expression using that column is an aggregate function.

A GROUP BY expression can only contain column names from the select list, but not those used only as arguments for vector aggregates.

The results of a standard GROUP BY with vector aggregate functions produce one row with one value per group."