On 8/18/06, Mark Blythe <[EMAIL PROTECTED]> wrote:
> On 8/18/06, Paul Henrich <[EMAIL PROTECTED]> wrote:
>> It seems postgres has a strange syntax/behavior for GROUP BY that becomes
>> difficult to work with when using SQL::Abstract and when working with joined
>> tables. Basically, any column you select must be used in the GROUP BY or in
>> an aggregate function.
>
> If I'm not mistaken, that is ANSI SQL syntax.  MySQL allows you to
> select other columns without using them in the GROUP BY, but that's an
> extension of the standard.

...where "extension of the standard" here means "crazy thing that
makes no sense."

    CREATE TABLE t (a INT, b INT, c INT);

    INSERT INTO t VALUES (1, 2, 3);
    INSERT INTO t VALUES (1, 2, 4);
    INSERT INTO t VALUES (1, 2, 5);
    INSERT INTO t VALUES (1, 2, 6);

Now guess what value c will have in the row returned by this query:

    SELECT a, SUM(b), c FROM t GROUP BY a;

Good old MySQL...

-John

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to