I'm trying to filter out records that have an invoice number that is similar but have some characters added to it. i don't want records where there is a credit invoice present. invoice numbers can look like 6245GE134
whereas credit invoice often have 'CR' added to them ,this varies however.
I've tried to make various lines with a replace statement:
where invoiceNr not in (select replace (invoiceNr, 'cr' ,'') from
tblinvoices where invoicenr like '%cr' and strType = 'credit'
the problem is, some fields have 'cr' added to them while others use 'credit' or even something completely different. ideally i want to be able to use wildcards to cover all posibilities, see underneath
where invoiceNr not like '%' + (select invoiceNr from tblinvoices where
strtype = 'credit' ) + '%'
expected: it filters out all records where invoicenr appears in invoicenr that is credit type
actual:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.