我在使用以下 SQL 查询的 where 语句时遇到问题:
select distinct
[columns]
from ifsapp.customer_order_inv_head coih
left outer join ifsapp.identity_invoice_info iii
on coih.company = iii.company
and coih.identity = iii.identity
and iii.party_type_db = 'CUSTOMER'
left outer join ifsapp.customer_info_address cia
on coih.identity = cia.customer_id
and cia.address_id = '1'
left outer join ifsapp.customer_info_comm_method cicm
on coih.identity = cicm.customer_id
and cicm.address_id = '1'
where coih.invoice_date between to_date('&date_from', 'dd/mm/yyyy') and to_date('&date_to', 'dd/mm/yyyy')
and iii.group_id not in ('1', '2', '3', '4', '5', '6', '7', '8', '9')
and iii.pay_term_id <> 'SO'
and ifsapp.fb_dev_utils_api.is_einvoice_customer(coih.identity) = 'FALSE'
and ifsapp.fb_dev_utils_api.is_edi_customer(coih.identity) = 'FALSE'
and coih.net_amount >= ('&Value')
and upper(cicm.name) not like upper(nvl('&Optout', 'blank'))
and upper(iii.group_id) like upper(nvl('&Cust_Group', '%'))
and upper(coih.company) like upper(nvl('&Company', '%'))
以上工作正常(如果有点慢),但是我也只想排除iii.group_id = '10'
但coih.contract not like 'S%'
我无法正确使用语法。我尝试了以下方法:
or (coih.contract not like 'S%' and iii.group_id = '10')
非常感激任何的帮助。