user3731025
user3731025

Reputation: 21

Removing part of a column in SQL

I am attempting to select both an entire column, and then just part of the column, but can't seem to make a trim function work. Not sure if this is even the correct function.

My Starting Data, which I still want, is like this:

JOB_CODE
02-7740-00
02-7741-01
02-7790-10
02-7821-05

I want an additional column that just gives me the last 2 digits of that string, so it would look like this:

JOB_CODE     Cost_Center
02-7740-00    00
02-7741-01    01
02-7790-10    10
02-7821-05    05

Upvotes: 1

Views: 41

Answers (1)

vhadalgi
vhadalgi

Reputation: 7189

Try using RIGHT

select JOB_CODE,RIGHT(JOB_CODE,2) as Cost_Center from table

DEMO

Upvotes: 2

Related Questions