Removing last 3 right chars

How to remove the last 3 right chars from data?
zachvaldezAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Paul MacDonaldDirector, Information SystemsCommented:
Something like...
SUBSTRING(field, 1, LEN('field') - 3)
0
_agx_Commented:
Which DBMS (SQL Server, MySQL, ...)?

What should the result be if the value is less than 3 chars or null?
0
Paul JacksonSoftware EngineerCommented:
I prefer using LEFT :

SELECT LEFT(column_name, LEN(column_name) - 3) FROM TableName
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

johnsoneSenior Oracle DBACommented:
Answer is certainly database dependent.

While these work in SQL Server:

SUBSTRING(field, 1, LEN(field) - 3)
LEFT(column_name, LEN(column_name) - 3)

In Oracle, that would be:

substr(field,1,length(field) - 3)

Oracle doesn't have a LEFT function.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mark EdwardsChief Technology OfficerCommented:
For anyone wondering what technology(s) a question pertains to, they can be found listed at the top between the question title and the author's original input.  In this case, the technologies given were:

Query Syntax, SQL, Microsoft SQL Server

So my guess would be "SQL Server"....
0
_agx_Commented:
@Mark Edwards - Think that was just added. IIRC, the original tags were just "Query Syntax" and "SQL" (no mention of the dbms being SQL Server).

@zachvaldez - What should be returned if the value being parsed is null or less than 3 chars? Empty string, null?
0
Paul JacksonSoftware EngineerCommented:
Only query syntax is visible to me, the others don't show unless click the edit topics icon.
0
Mark EdwardsChief Technology OfficerCommented:
ahhhh.  Yea, that would have made it a little more difficult............
0
johnsoneSenior Oracle DBACommented:
Yes, original tags did not contain SQL Server.  That is where the confusion comes from.

While a lot of things are portable, these kinds of function calls unfortunately aren't.
0
slightwv (䄆 Netminder) Commented:
FYI

>>Yes, original tags did not contain SQL Server

Correct.

>>they can be found listed at the top between the question title

I added SQL Server based on zachvaldez's previous questions.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.