on 10-23-2009 7:41 PM
Hi there,
I have an object with 10 digits numbers in that as shown below. We use Sql Server 2008.
eg: 6786542341
9875642342
I have to take out the last digit of the number , which i have taken off using this formula
left(tablename.columnname,len(tablename.columnname)-1) .
But i want to include a case statement that if the number is ending with 1 then keep the number as it is but if the number is ending with 2 use left(tablename.columnname,len(tablename.columnname)-1) .
Any inputs would be appreciated.
Thanks
Abhi
Hi Abilash,
Try like this,
Case when n0 % 10 = 1 then no else
left(tablename.columnname,len(tablename.columnname)-1)
...........
............
EndCase.
Cheers,
Suresh Aluri.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try this syntax:
CASE
WHEN right(tablename.columnname, 1) = 1 THEN tablename.columnname
WHEN right(tablename.columnname, 1) = 2 THEN left(tablename.columnname,len(tablename.columnname)-1)
ELSE whatever you want
END
Regards,
Didier
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.