Question: In my sql database I have a table like "REG\_DET", This table mainly include 3 data member. NAME,AGE,SSN. Here SSN is a string include more than 10 character. Here my problem is when i read SSN from the table i need only last 4 character that is

Eg. `Rohith , 25 , 1023456457`

result only include `Rohith , 25 ,6457`(last 4 character of SSN)

Is It possible to do it in a sql select query(at the time of selection). If anyone know pls help me

Answer: 
Yes it is possible with the [`RIGHT`](http://msdn.microsoft.com/en-us/library/ms177532.aspx) function:

```
SELECT NAME, AGE, RIGHT(SSN, 4) FROM REG_DET

```
To get the last 4 digits from the `SSN` column , you can also use `SUBSTRING`. If the length of the SSN column is 10, then you can use the following query:

```
 SELECT NAME, AGE, SUBSTRING(SSN, 6, 4) FROM REG_DET

```