If you want strings that do not start witn NA
then:
SELECT *
FROM tz_customers c
WHERE c.customercode NOT LIKE 'NA%'
If you want strings that don't contain NA
anywhere then:
SELECT *
FROM tz_customers c
WHERE c.customercode NOT LIKE '%NA%'
If you want strings that aren't exactly NA
then:
SELECT *
FROM tz_customers c
WHERE c.customercode <> 'NA'
If you want strings that only have alphabet characters then you can use TRANSLATE
to strip the allowed characters and test whether the remaining string is empty (NULL
):
SELECT *
FROM tz_customers c
WHERE TRANSLATE(
c.customercode,
'1abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'1'
) IS NULL
If you want to combine the two then:
SELECT *
FROM tz_customers c
WHERE TRANSLATE(
c.customercode,
'1abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'1'
) IS NULL
AND c.customercode <> 'NA'
So for the sample data:
CREATE TABLE tz_customers ( customercode ) AS
SELECT 'NA' FROM DUAL UNION ALL
SELECT 'BANANA' FROM DUAL UNION ALL
SELECT 'BANANA2' FROM DUAL;
This outputs:
| CUSTOMERCODE |
| :----------- |
| BANANA |
db<>fiddle here