|
|||||||||||
|
Re: [GENERAL] SQL Query
From: A. Kretschmer <andreas.kretschmer(at)schollglas.com>
Date: Wed Dec 05 2007 - 06:15:53 EST
test=# create table Ashish ( x int, y text);
CREATE TABLE
>> 1 abc >> 2 pqr >> 3 yxz >> 4 lmn >> 1 lmn >> 2 xyz >> \. test=*# CREATE FUNCTION my_aggregate(text,text) RETURNS text AS ' SELECT CASE WHEN $1 <> '''' THEN $1 || '':'' || $2 ELSE $2 END; ' LANGUAGE sql IMMUTABLE STRICT; CREATE AGGREGATE my_comma (basetype=text, sfunc=my_aggregate , stype=text, initcond='' ); CREATE FUNCTION CREATE AGGREGATE test=*# select x, my_comma(y) from ashish group by x; x | my_comma ---+---------- 4 | lmn 3 | yxz 2 | pqr:xyz 1 | abc:lmn (4 rows) Okay, i forgot to sort and the chars are in lower case... 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 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanlyReceived on Wed Dec 5 06:17:09 2007 This archive was generated by hypermail 2.1.8 : Mon Jun 16 2008 - 21:23:04 EDT |
||||||||||
|
|||||||||||