Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Trying to simplify an sql query
I am using the following sql query which I feel could be simplified, but I don't know how. For t1, fields (project + year) form the Pr Key.
select t1.location from t1 aa, t2 t2
where aa.project = t2.project and aa.year = t2.year and aa.month =
t2.month
and exists
(select 1 from t1 bb where aa.project = bb.project and aa.year =
bb.year
having count(*) = 1
group by bb.project, bb.year, bb.month
)
I think I have tried the following construct for the subquery but it hanged the database; maybe I tried a query which is slightly different than the one I am quoting below, but I don't want to risk hanging the database again.
(select 1 from null having count(*) = 1
group by aa.project, aa.year, aa.month)
Thanks in advance. Received on Mon Apr 17 2006 - 20:07:03 CDT