pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Reuven Abliyev <reuvenab@gmail.com>
To: Penchalaiah P. <penchalaiahp@infics.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Needs Query
Date: Tue, 8 May 2007 09:00:25 -0500
Message-ID: <1aa8c50f0705080700i670b5c6dpce0076ae02fbbb13@mail.gmail.com> (raw)
In-Reply-To: <20070508125854.GE19006@a-kretschmer.de>
References: <A70AE049E81A6A40879D5DC0AC8C38C908E71F76@venus.infics.com>
	<20070508125854.GE19006@a-kretschmer.de>

or if you want it in the one query:

>create table _t(f varchar(50));

select f, case when substr(f, length(f), 1)= substr(f, length(f)-1, 1) then
regexp_replace(f, substr(f, length(f), 1)||'+$', substr(f, length(f), 1))
else f end from _t where length(f)>1;




On 5/8/07, A. Kretschmer <andreas.kretschmer@schollglas.com> wrote:
>
> am  Tue, dem 08.05.2007, um 17:48:47 +0530 mailte Penchalaiah P.
> folgendes:
> >
> >
> >
> >
> >
> >
> >
> >
> > In a table, a column contains
> >
> >
> >
> > Suneelllllllllllllll
> >
> > Sudhakarrrrrrrrrr
> >
> > Vivekkkkkkkkkk
> >
> > Ramanaaaaaaaaa
> >
> >
> >
> >
> >
> > But my output is
> >
> > Suneel
> >
> > Sudhakar
> >
> > Vivek
> >
> > Ramana
> >
> >  I want a query to get my output like above??..
>
> write a stored proc. within this proc: (oversimplified)
>
> - calculate the length of the string with length() -> length
> - extract substring(string, length, length) -> last_char
> - regexp_replace(string, last_char||'*$', last_char)
>
>
> Andreas
> --
> Andreas Kretschmer
> Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
> GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>

view thread (3+ messages)

Message-ID: <1aa8c50f0705080700i670b5c6dpce0076ae02fbbb13@mail.gmail.com>
Permalink:  ../1aa8c50f0705080700i670b5c6dpce0076ae02fbbb13@mail.gmail.com/
Also on:    postgresql.org/message-id/1aa8c50f0705080700i670b5c6dpce0076ae02fbbb13@mail.gmail.com

 · 

reply

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: reuvenab@gmail.com, penchalaiahp@infics.com
  Subject: Re: Needs Query
  In-Reply-To: <1aa8c50f0705080700i670b5c6dpce0076ae02fbbb13@mail.gmail.com>

* 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