Reputation: 731
Table qqq:
|**type** | **ColB** |
-+-----------+-----------+-
| A | 0030-0000 |
| A | 0234-0001 |
| A | 0001-0003 |
type
is Varchar
,
ColB
is Varchar
I would like to trim all zeroes in leading and trailing poisition. The expected outcome is :
|**type** | **ColB** |
-+-----------+-----------+-
| A | 30- |
| A | 234-0001 |
| A | 1-0003 |
This is query I wrote:
select type, TRIM(both '0' FROM colB) From qqq
where type = 'A';
However, my output is:
|**type** | **ColB** |
-+-----------+-----------+-
| A | 0030- |
| A | 0234-0001 |
| A | 0001-0003 |
the trim (both
does not working out...
Upvotes: 0
Views: 59
Reputation: 2246
After much diagnosis via chat I began to suspect that there was a leading space in the strings. I suggested the following as an answer...
SELECT TRIM( '0' FROM TRIM( fieldName ) )
FROM tableName;
Upvotes: 1