Query GROUP BY

Поиск
Список
Период
Сортировка
От Oleg Lebedev
Тема Query GROUP BY
Дата
Msg-id 993DBE5B4D02194382EC8DF8554A527303354D@postoffice.waterford.org
обсуждение исходный текст
Список pgsql-general
I have two similar queries. The first one uses an alias in the GROUP BY clause, which causes an error. The second query uses the actual column name in the GROUP BY clause and passes.
Note that the other GROUP BY parameter is an alias in both cases. So, why would GROUPing work for one alias, but not for the other?
 
Q1 (Fails):
SELECT     c.objectid AS charid,
                c.charname AS charname,
                SUM (num)
                FROM speccharacter c
                LEFT OUTER JOIN media m
                    ON     m.mediachar = c.objectid
                    AND    m.mediatype = '2'
GROUP BY charid, charname
ORDER BY charname
 
Q2 (Runs):
SELECT c.objectid AS charid,
                c.charname AS charname,
                SUM (num)
FROM speccharacter c
                LEFT OUTER JOIN media m
                    ON     m.mediachar = c.objectid
                    AND    m.mediatype = '2'
GROUP BY charid, c.charname
ORDER BY charname
 
 
 

*************************************

This email may contain privileged or confidential material intended for the named recipient only.
If you are not the named recipient, delete this message and all attachments.
Any review, copying, printing, disclosure or other use is prohibited.
We reserve the right to monitor email sent through our network.

*************************************

В списке pgsql-general по дате отправления:

Предыдущее
От: merlyn@stonehenge.com (Randal L. Schwartz)
Дата:
Сообщение: Open Source Development Lab resources
Следующее
От: Christoph Dalitz
Дата:
Сообщение: Re: Running PostgreSQL on Windows