Возможно, вам потребуется дважды объединить одну и ту же таблицу, основываясь на code_ty; например:
SQL> with query1(id, classification_code, category_code) as(
2 select 123, 1, 3 from dual union all
3 select 456, 2, 4 from dual union all
4 select 789, 1, 3 from dual
5 ),
6 query2(code_type, code_1, code_desc) as (
7 select 'LCL', 1, 'TOMATOES' from dual union all
8 select 'LCL', 2, 'DURIAN' from dual union all
9 select 'LCA', 3, 'VEGETABLE' from dual union all
10 select 'LCA', 4, 'FRUITS' from dual
11 )
12 select id, LCL.code_desc, LCA.code_desc
13 from query1
14 inner join query2 LCL
15 on(LCL.code_1 = query1.classification_code)
16 inner join query2 LCA
17 on(LCA.code_1 = query1.category_code);
ID CODE_DESC CODE_DESC
---------- --------- ---------
123 TOMATOES VEGETABLE
789 TOMATOES VEGETABLE
456 DURIAN FRUITS
или даже следующее, в зависимости от ваших данных:
select id, LCL.code_desc, LCA.code_desc
from query1
inner join query2 LCL
on(LCL.code_1 = query1.classification_code
and LCL.code_type = 'LCL')
inner join query2 LCA
on(LCA.code_1 = query1.category_code
and LCA.code_type = 'LCA')
Кроме того, вам лучше использовать ANSI join; Ваш запрос должен быть:
select a.ID,
a.CLASSIFICATION_CODE,
a. CATEGORY_CODE
from a
inner join b
on(
a.DIV = b.DIV
and a.TYPE = b.TYPE
and a.DIST = b.DIST
and a.BS = b.BS
and a.LOT = b.LOT
)
where locality = 'xxx'