Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Outer join
What you did was tell it to do an outer join for any description that
didn't exist in the table, not for any description that didn't exist in
the survey id group. Did I explain that well? In order to do
what you want you will need to do something like:
select a.survey_id, b.description, count(*) from
(select distinct d.survey_id, e.description_id from estatdesc e, estat d)
c
estatdesc b, estat a
where a.survey_id = c.survey_id
and b.description_id = c.description_id and a.description_id (+) = b.description_id group by a.survey_id, b.description
I haven't tested this and have no idea if this will work at all, but do you see what I'm going for? You need some sort of intermediate table that will provide a list of all descriptions attached to each survey id.
At 05:10 PM 7/3/01 -0800, you wrote:
I'm
sure the answer is in front of me, but I don't see it......
Outer join on two tables, one
with 1000+ survey rows, one with 11 description rows. Problem is
the user wants to see all eleven description rows for all surveys,
whether or not there are rows for the descriptions.
This works as expected:
SQL> select b.survey_id,
substr(a.description,1,25), count(*)
2 from
tracking.emailstatusdescriptions a ,tracking.emailstatus b
3 where
a.description_id = b.description_id(+)
4 and
b.survey_id(+) = 140
5 group by
survey_id(+), a.description ;
SURVEY_ID
SUBSTR(A.DESCRIPTION,1,25 COUNT(*)
11 rows selected.
When I remove the 'and
b.survey_id(+) = 140' to include all surveys,
the outer join fails to produce
all 11 rows per survey_id.
SQL> select b.survey_id,
substr(a.description,1,25), count(*)
2 from
tracking.emailstatusdescriptions a ,tracking.emailstatus b
3 where
a.description_id = b.description_id(+)
4 group by
b.survey_id(+), a.description ;
SURVEY_ID
SUBSTR(A.DESCRIPTION,1,25 COUNT(*)
47 rows selected.
SQL> desc
tracking.emailstatus
Name
Null? Type
--------------------
-------- -------------------------------------------------
Name
-------------------- -------- --------------------------
COUNT(*)
If this looks familiar and someone sees my error, please let me know.
Thank you and best regards,
Linda Hagedorn Received on Tue Jul 03 2001 - 20:30:44 CDT
![]() |
![]() |