Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id CD3E89FB99A for ; Thu, 22 Feb 2007 07:38:54 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 60786-09 for ; Thu, 22 Feb 2007 07:38:47 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.239]) by postgresql.org (Postfix) with ESMTP id 969529FB836 for ; Thu, 22 Feb 2007 07:38:51 -0400 (AST) Received: by nz-out-0506.google.com with SMTP id i11so149380nzh for ; Thu, 22 Feb 2007 03:38:50 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=lblVo1GaKIKnMMYzXIKq5PfhuAhIcYfnvfU90dsJyazSP/h/+aL4kUY6GbuO2xGP0IaM//PJIQlr+S3D3n3hyBCB15LToXBRUYBnFoF8tVw6qD/No0aZlIeF2I+351f30onXn1gqd7+0tPv9tXADk0ph0wFOa/CjO6BZ4HpF82M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=qtZxL6FbMOHnPQd7fnfzJI+cpYk+nA8OySeHyZDagQgteSYuAwjCO4Dw0BsSJ3TH7NwpFGQ9IGGEKYLXhyzmZrSqkVFdzrW+KvJBbT6eIA87E162h18wnNyx7JlWcLhS+wpVQKmqWgW+Ei4428lIYoyQK7I6z+uT8YCwt3h7ju0= Received: by 10.65.152.17 with SMTP id e17mr864914qbo.1172144330371; Thu, 22 Feb 2007 03:38:50 -0800 (PST) Received: by 10.64.184.11 with HTTP; Thu, 22 Feb 2007 03:38:50 -0800 (PST) Message-ID: <2cfc7c940702220338h3eb4ec97p8cd759cb7a36d775@mail.gmail.com> Date: Thu, 22 Feb 2007 12:38:50 +0100 From: "Sergio Andreozzi" To: pgsql-general@postgresql.org Subject: how to generate a list of distinct scalar values from a column which type is array In-Reply-To: <2cfc7c940702211021u1ba47031l25112a69cfb18338@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_15128_10613444.1172144330337" References: <2cfc7c940702211021u1ba47031l25112a69cfb18338@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.785 tagged_above=0 required=5 tests=AWL, BAYES_40, HTML_30_40, HTML_MESSAGE, SPF_PASS X-Spam-Level: X-Archive-Number: 200702/1208 X-Sequence-Number: 109698 ------=_Part_15128_10613444.1172144330337 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Dear all, given a column which type is for instance varchar(20)[], is it possible via SQL to generate the list of distinct scalar values? e.g.: col1 row 1: (aaa, bb, c) row 2: (dddd, eeee) row 3: (aaa, eeee) the query should return: aaa bb c dddd eeee if not, I guess the approach is to use stored procedure. Any code snippet/suggestion? Thanks, Sergio ------=_Part_15128_10613444.1172144330337 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Dear all,

given a column which type is for instance varchar(20)[], is it possible via SQL to generate the list of distinct scalar values?


e.g.:
             col1
row 1: (aaa, bb, c)
row 2: (dddd, eeee)
row 3: (aaa, eeee)

the query should return:

aaa
bb
c
dddd
eeee

if not, I guess the approach is to use stored procedure. Any code snippet/suggestion?

Thanks, Sergio

------=_Part_15128_10613444.1172144330337--