Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: sql help - group by with subselect

Re: sql help - group by with subselect

From: Dave Fowler <d.fowler_at_smmj.com>
Date: Tue, 24 Apr 2001 20:46:10 GMT
Message-ID: <mClF6.1800$G04.232202@newsread2.prod.itd.earthlink.net>

Ed,
If you put the subquery in the group by it will work. You can't have alias references in group by

    Try that with any function call using a column alias and the same error will occur.

  select col_1,to_char(sysdate) today,count(*) row_count from your_table   group by col_1,today
  if you change group by to col_1,to_char(sysdate)    it will work.

Your case would required the "selects" subqueries in the group by.

hth
Dave Fowler

"ed zappulla" <zappullae_at_rcn.com> wrote in message news:9c3u9j$sk$1_at_bob.news.rcn.net...
> Does anyone know why I can't use the country or state in the group by?
>
> SQL>
> select airport_cd,
> (select country.name from country where country_id=airport.country_id)
 as
> country,
> (select state.name from state where state_id=airport.state_id) as state,
> city
> from airport,
> group by airport_cd, country, state
> order by airport_cd
> ;
> group by vendor.name, airport_cd, country, state
> *
> ERROR at line 9:
> ORA-00904: invalid column name
>
>
>
>
Received on Tue Apr 24 2001 - 15:46:10 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US