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
Solved

Exclude numbers that start with 7

Posted on 2014-09-12
4
244 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: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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL0338 Error received on query 3 301
DB2 Drivers Windows Server - Database port number 4 444
ODBC connect from ms access to DB2 3 93
DB2 V9.7 restore 5 45
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 (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

840 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