From: Ken Hill <ken@scottshill.com>
To: Bruno Wolff III <bruno@wolff.to>
Cc: superboy143 <superboy143@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: query
Date: Fri, 10 Feb 2006 08:22:03 -0800
Message-ID: <1139588523.29808.10.camel@localhost.localdomain> (raw)
In-Reply-To: <20060210061129.GA26002@wolff.to>
References: <2798161.post@talk.nabble.com>
<20060210061129.GA26002@wolff.to>
On Fri, 2006-02-10 at 00:11 -0600, Bruno Wolff III wrote:
> On Tue, Feb 07, 2006 at 01:45:50 -0800,
> "superboy143 (sent by Nabble.com)" <lists@nabble.com> wrote:
> >
> > I have a table in which I have a field with format like 100101. It has many values like 100101, 100102, 100103, 100201, 100202, 100301. I have to write a query such that I have to get only distinct values such that they contain only the substring I need. If I give 10 as substring, then it should return only 100101 or 100102 but not both i.e if the last two characters are not same it should not return both of them. It should return only values starting with 10 the middle two values should be distinct and the last two characters may be anything.
>
> You can probably use the Postgres extension DISTINCT ON to do what you want.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
Try substring(column,1,4). That should return values of 1001, 1002, 1003
when grouped.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ken@scottshill.com, bruno@wolff.to, superboy143@gmail.com
Subject: Re: query
In-Reply-To: <1139588523.29808.10.camel@localhost.localdomain>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox