var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Why Am I an Error with this Query?
I am trying to run a query that will return me just the last four digits of a person's social security number. I tried the following in my SELECT statement:
SELECT Distinct right(A.MBR_SSN_NBR, 4 ) as SSN
Unfortunately, I get an error complaining that the data type or length of RIGHT is incorrect.
It looks like this function only works on character fields. If I use
SELECT Distinct right('A.MBR_SSN_NBR', 4 ) as SSN
The query runs and returns _NBR.
IS there something I'm missing here or is there a way to convert the SSN to character in my query?
You should use
As a hack, you can also use
I assume the latter one will be more efficient
Last edited by sathyaram_s; 08-25-11 at 10:37.
Reason: removed [quote] and added [code]
Visit the new-look IDUG Website
, register to gain access to the excellent content.
You are right!
It looks like this function only works on character fields.
You may want to use DIGITS function like ...
... is there a way to convert the SSN to character in my query?
Note: function CHAR(number) may return a value with left justified.
RIGHT( DIGITS(a.mbr_ssn_nbr), 4 ) AS ssn
So, RIGHT( CHAR(...), 4 ) may return a value including some trailing blanks.
Last edited by tonkuma; 08-25-11 at 10:45.
Reason: Add note.