Re: finding columns that have three or fewer distinct characters

Поиск
Список
Период
Сортировка
От Osvaldo Rosario Kussama
Тема Re: finding columns that have three or fewer distinct characters
Дата
Msg-id 47CEEAA3.3040004@gmail.com
обсуждение исходный текст
Ответ на finding columns that have three or fewer distinct characters  (Jeff Frost <jeff@frostconsultingllc.com>)
Ответы Re: finding columns that have three or fewer distinct characters
Список pgsql-sql
Jeff Frost escreveu:
> I've got an interesting one...I'm trying to find columns that have three 
> or fewer distinct characters (for example, "aaaaaaaaaa").  Wondering if 
> I need to write a function or if someone has an idea how to do it with 
> built in functions and/or pattern matching?
> 
> I think the thing to do would be to lowercase everything, then remove 
> all duplicate chars and spaces, then use length() on that, but it's not 
> obvious to me how I might remove the duplicate chars with the pattern 
> matching support in the docs.
> 

Try:
SELECT  array_to_string(array(    SELECT DISTINCT lower(substr('aabbcdddef  AB',i,1))           FROM
generate_series(1,length('aabbcdddef AB'))                s(i))                  , '');
 

Osvaldo


В списке pgsql-sql по дате отправления:

Предыдущее
От: Colin Wetherbee
Дата:
Сообщение: Re: finding columns that have three or fewer distinct characters
Следующее
От: Jeff Frost
Дата:
Сообщение: Re: finding columns that have three or fewer distinct characters