From: | "Reuven Abliyev" <reuvenab(at)gmail(dot)com> |
---|---|
To: | "Penchalaiah P(dot)" <penchalaiahp(at)infics(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Needs Query |
Date: | 2007-05-08 14:00:25 |
Message-ID: | 1aa8c50f0705080700i670b5c6dpce0076ae02fbbb13@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(dot)kretschmer(at)schollglas(dot)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
>
From | Date | Subject | |
---|---|---|---|
Next Message | Rommel the iCeMAn | 2007-05-08 14:10:14 | Re: Error: Input string was not in a correct format |
Previous Message | Jonah H. Harris | 2007-05-08 13:30:33 | Re: Query RE using COPY |