Solved

Exclude numbers that start with 7

Posted on 2014-09-12
4
251 Views
Last Modified: 2014-09-12
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
Comment
Question by:d27m11y
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 40319344
I think DB2 uses the same basic syntax as Oracle:
select accountnumbers from some_table where accountnumbers not like '7%'
0
 
LVL 45

Expert Comment

by:Kent Olsen
ID: 40319347
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
 

Author Closing Comment

by:d27m11y
ID: 40319357
Thank you, I tried to use not like similar to Oracle and it worked in DB2.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question