我有下面的SQL查询的WHERE语句麻烦:的Oracle 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')
任何帮助将不胜感激。
如果合同不是'S%',我只想要返回group_id 10,但是我希望所有其他group_id都可以返回,而不管合同是什么。 如果group_id为10,但排除所有其他group_id,则上述解决方案的行为正确。 – pwl
由于戈登已经指定我看到没有理由为什么这不起作用 AND NOT(coih.contract NOT LIKE's%'and iii.group_id ='10') – Zakerias
我要么错过了'而不是...'或者在我以任何方式写我的评论之后编辑答案,我都非常感谢你的帮助。 – pwl