wahyu kur wahyu kur - 6 months ago 25
SQL Question

ORA-00920: invalid relational operator 3

create or replace view test as
select b.npm1,b.nama,b.IPS,a.ket as ket1,b.IPK,a.ket as ket2
from KHS b left join keterangan a on a.nilai = IPS and
left join keterangan a on a.nilai = IPK


please help me, what the mistake from my code !!

Answer

First, you have a stray 'and' between your two joins (that's probably the source of the error). Second, you need to alias your tables differently even if you want to join to the same table twice. The resulting code should look something like this:

CREATE OR REPLACE view test AS
SELECT 
    b.npm1,
    b.nama,
    b.IPS,
    a1.ket AS ket1,
    b.IPK,
    a2.ket AS ket2
FROM KHS b 
    LEFT JOIN keterangan a1 
        ON a1.nilai = b.IPS 
    LEFT JOIN keterangan a2
        ON a2.nilai = b.IPK