我尝试在select上进行内连接。我的选择语句如下所示
SELECT con.fpd_no,
con.contract_no,
cm.cust_name,
(select cm.cust_name, TRIM(cm.address) || ', ' || TRIM(cm.zipcode) || ', ' || TRIM(klm.kelurahan_desc) || ', ' || TRIM(kcm.kecamatan_desc) || ', ' || TRIM(kbm.kabupaten_desc) || ', ' || TRIM(prm.propinsi_desc)
from customer_master cm
inner join kelurahan_master klm on klm.kelurahan_id=cm.kelurahan_id
inner join kecamatan_master kcm on kcm.kecamatan_id=klm.kecamatan_id
inner join kabupaten_master kbm on kbm.kabupaten_id=kcm.kabupaten_id
inner join propinsi_master prm on prm.propinsi_id=kbm.propinsi_id;) as address,
con.principal_amount
FROM contract con
JOIN customer_master cm ON cm.cust_no = con.cust_no
WHERE con.deal_code = 'A005'
AND con.fpd_date BETWEEN '01-01-2016' AND '31-01-2016'
AND con.fpd_no = '0103006116'
AND con.objt_group = 'MOTOR';
但是我收到了这个错误:
ORA-00911:无效字符。
答案 0 :(得分:0)
删除subselect上的分号,并确保select只返回一行
SELECT con.fpd_no, con.contract_no, cm.cust_name, (select distinct cm.cust_name, TRIM(cm.address) || ', ' || TRIM(cm.zipcode) || ', ' || TRIM(klm.kelurahan_desc) || ', ' || TRIM(kcm.kecamatan_desc) || ', ' || TRIM(kbm.kabupaten_desc) || ', ' || TRIM(prm.propinsi_desc)
from customer_master cm
inner join kelurahan_master klm on klm.kelurahan_id=cm.kelurahan_id
inner join kecamatan_master kcm on kcm.kecamatan_id=klm.kecamatan_id
inner join kabupaten_master kbm on kbm.kabupaten_id=kcm.kabupaten_id
inner join propinsi_master prm on prm.propinsi_id=kbm.propinsi_id) as address, con.principal_amount
FROM contract con
JOIN customer_master cm ON cm.cust_no = con.cust_no
WHERE con.deal_code = 'A005'
AND con.fpd_date BETWEEN '01-01-2016' AND '31-01-2016'
AND con.fpd_no = '0103006116'
AND con.objt_group = 'MOTOR';