[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Group By SubQuery...

Posted on 2006-11-07
3
Medium Priority
?
1,008 Views
Last Modified: 2008-01-09
Hi experts,

I would like to group by the subquery but when I try I get the error "ORA-22818: subquery expressions not allowed here."

What am I doing wrong or what is the alternative? Thanks.

My query:

select distinct
count(p.person_code) as emacount,
(select byd_acc_year from brom_year_dates
where byd_fund_year = ema.FUNDING_YEAR)
from people p, ema
where p.EMA_ID is not null
and ema.PERSON_CODE = p.PERSON_CODE
and ema.FUNDING_YEAR = 13
group by (select byd_acc_year from brom_year_dates
where byd_fund_year = ema.FUNDING_YEAR)
0
Comment
Question by:bromley_college
  • 2
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 17887741
what about this:
select count(person_code) emacount, x
from (
select p.person_code ,
(select byd_acc_year from brom_year_dates
where byd_fund_year = ema.FUNDING_YEAR) x
from people p, ema
where p.EMA_ID is not null
and ema.PERSON_CODE = p.PERSON_CODE
and ema.FUNDING_YEAR = 13
)
group by x
0
 

Author Comment

by:bromley_college
ID: 17887779
I am expecting something like

EMACOUNT     X
613                0607
501                0506
714                0405


However, your query just gives me:
EMACOUNT     X
613                0607


0
 

Author Comment

by:bromley_college
ID: 17887788
Nope sorry, my fault. I didn't need the line "and ema.FUNDING_YEAR = 13"

Your query works fine. Thank you :)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question