POSTGRESQL HOW TO DISTINCT Fullwidth

Viewed 33

I have data in my dataset like below,in varchar data type.

123456789X
123456789x
123456789x
123456789X

Please advise how to use distinct lower to distinct above 4 to 1? Thanks.

I found how to solve this problem by:

SELECT DISTINCT(TRANSLATE(LOWER(telephone),
'-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'))
2 Answers

This is the solution:

SELECT DISTINCT(TRANSLATE(LOWER(telephone),
'-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'))

I'd remove the spaces (using replace) and then apply distinct:

SELECT DISTINCT REPLACE(data, ' ', '')
FROM   mytable
Related