[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • 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

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

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