• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

Exclude numbers that start with 7

I have a list of accountnumbers from the query where I need to exclude accountnumbers which start with 7. Can I use regexp or is there any easier way to use it in DB2.

Please suggest !
0
d27m11y
Asked:
d27m11y
1 Solution
 
slightwv (䄆 Netminder) Commented:
I think DB2 uses the same basic syntax as Oracle:
select accountnumbers from some_table where accountnumbers not like '7%'
0
 
Kent OlsenData Warehouse Architect / DBACommented:
Hi D27,

If the account number is stored as a string, the easiest is to filter on it.

SELECT * FROM mytable WHERE left (account_no, 1) <> '7';

If the account number is numeric, there's a bit more work to do.  But if the account number is a consistent length, it gets easy, too.


Kent
0
 
d27m11yAuthor Commented:
Thank you, I tried to use not like similar to Oracle and it worked in DB2.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now