pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedusing custom column names in a group by clause
2+ messages / 2 participants
[nested] [flat]
* using custom column names in a group by clause
@ 2001-07-13 16:33 Matt Rinkenberger <mrink@avaya.com>
2001-07-17 18:37 ` Re: using custom column names in a group by clause Josh Berkus <josh@agliodbs.com>
0 siblings, 1 reply; 2+ messages in thread
From: mrink@avaya.com @ 2001-07-13 16:33 UTC (permalink / raw)
To: pgsql-sql
The following select sets two custom column names using the same
original column name. When I try to include a custom column name in a
group by clause I get ORA-00904: invalid column name from Oracle. How
can I access a column name I created in the group by clause?
Here's the SQL: DISP is the column causing the error
select userid,matlid,wsid,
substr(note,instr(note,'Status') + 8,(instr(note,',',1,3) -
(instr(note,'Status') + 8))) as DISP,
sum(substr(note,instr(note,'Qty') + 5,(instr(note,',',1,1) -
(instr(note,'Qty') + 5)))) as QTY,
action
from ise_prodordlog
where userid = '4500925'
and action in ('CompleteItem','UndoCompleteItem')
and actiontime >= to_date('06/20/2001 00:00:00','MM/DD/YYYY
HH24:MI:SS')
and actiontime < to_date('06/30/2001 00:00:00','MM/DD/YYYY
HH24:MI:SS')
group by userid,matlid,wsid,DISP,action
order by userid,matlid,wsid,DISP,action;
Matt Rinkenberger
Avaya, Inc.
mrink@avaya.com
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: using custom column names in a group by clause
2001-07-13 16:33 using custom column names in a group by clause Matt Rinkenberger <mrink@avaya.com>
@ 2001-07-17 18:37 ` Josh Berkus <josh@agliodbs.com>
0 siblings, 0 replies; 2+ messages in thread
From: Josh Berkus @ 2001-07-17 18:37 UTC (permalink / raw)
To: pgsql-sql
Matt,
First of all, this is a PostgreSQL list, so we're not going to be able
to give you much help with Oracle.
> The following select sets two custom column names using the same
> original column name. When I try to include a custom column name in
> a
> group by clause I get ORA-00904: invalid column name from Oracle.
> How
> can I access a column name I created in the group by clause?
Second, I'd say that your answer is self-evident; use the real column
name rather than the custom column name. If the column is just being
aliased in order to display it twice, then it doesn't matter which one
you group by.
Third, Matt, PostgreSQL 7.1.2 DOES support aliasing in GROUP BY
clauses. Maybe it's time to switch databases?
select client_name as clname1, client_name as clname2, AVG(status)
from clients
group by clname1, clname2
-Josh Berkus
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh@agliodbs.com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-07-17 18:37 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-07-13 16:33 using custom column names in a group by clause Matt Rinkenberger <mrink@avaya.com>
2001-07-17 18:37 ` Josh Berkus <josh@agliodbs.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox