Removing last 3 right chars

How to remove the last 3 right chars from data?
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)
Which DBMS (SQL Server, MySQL, ...)?

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

SELECT LEFT(column_name, LEN(column_name) - 3) FROM TableName
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.

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"....
@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?
Paul JacksonSoftware EngineerCommented:
Only query syntax is visible to me, the others don't show unless click the edit topics icon.
Mark EdwardsChief Technology OfficerCommented:
ahhhh.  Yea, that would have made it a little more difficult............
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.
slightwv (䄆 Netminder) Commented:

>>Yes, original tags did not contain SQL Server


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

I added SQL Server based on zachvaldez's previous questions.
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.