Solved

Exclude numbers that start with 7

Posted on 2014-09-12
4
231 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
4 Comments
 
LVL 76

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:Kdo
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now