finding columns that have three or fewer distinct characters

From: Jeff Frost <jeff(at)frostconsultingllc(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: finding columns that have three or fewer distinct characters
Date: 2008-03-05 17:33:53
Message-ID: Pine.LNX.4.64.0803050912570.4804@discord.home.frostconsultingllc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

--
Jeff Frost, Owner <jeff(at)frostconsultingllc(dot)com>
Frost Consulting, LLC http://www.frostconsultingllc.com/
Phone: 650-780-7908 FAX: 650-649-1954

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Steve Midgley 2008-03-05 17:38:20 Re: using copy from in function
Previous Message David Fetter 2008-03-05 15:05:27 Re: [DOCS] Documenting a DB schema