Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

outer joining 2 tables

Rob JonesNov 30 2021

hi,
Using the following database version.
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0
I've got a 3 tables and only want the account name where the frequency type code is M. Here's my list of tables.
create table table1
(account_number varchar2(6));

insert into table1
(account_number)
values
('111111');

insert into table1
(account_number)
values
('222222');

insert into table1
(account_number)
values
('333333');

insert into table1
(account_number)
values
('444444');

create table table2
(frequency_type_id integer
,frequency_type_cd varchar2(1));

insert into table2
(frequency_type_id
,frequency_type_cd)
values
(1
,'D');

insert into table2
(frequency_type_id
,frequency_type_cd)
values
(2
,'M');

create table table3
(account_number varchar2(6)
,account_name varchar2(10)
,frequency_type_id integer); --fk to table2

insert into table3
(account_number
,account_name
,frequency_type_id)
values
('111111'
,'test1'
,1);

insert into table3
(account_number
,account_name
,frequency_type_id)
values
('222222'
,'test2'
,1);

insert into table3
(account_number
,account_name
,frequency_type_id)
values
('333333'
,'test3'
,1);

insert into table3
(account_number
,account_name
,frequency_type_id)
values
('444444'
,'test4'
,1);

commit;

My query is as follows.
select table1.account_number
,table3.account_name
from table1
left join table3
on table1.account_number = table3.account_number
left join table2
on table3.frequency_type_id = table2.frequency_type_id
and table2.frequency_type_cd = 'M';

I'm looking to show the account_name only when finding records where frequency_type_cd is M. However, my query always returns the account_name regardless if I use M or D as the frequency_type_cd. How could the query be modified so that it only shows the account_name when finding records where frequency_type_cd = M? Thanks!!!

This post has been answered by Frank Kulash on Dec 1 2021
Jump to Answer

Comments

LFHeckler

IMHO, the best forum to post this issue would be the SOA Forum: https://forums.oracle.com/community/developer/english/fusion_middleware/soa_%26_process_management/soa_suite_3

Anyway, make sure your SOA server can fully access the endpoint and XSD for the webservice  consumed by your process.

If you have remote references in your composite.xml or in any wsdl/xsd used in your project, this validation occurs even in deploy time.

Regards

Luis Fernando Heckler

1 - 1

Post Details

Added on Nov 30 2021
9 comments
149 views