Query GROUP BY

Started by Oleg Lebedevabout 23 years ago1 messagesgeneral
Jump to latest
#1Oleg Lebedev
oleg.lebedev@waterford.org

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.

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