Group: pgsql.general


Subject: SQL Query
From: Rolf Østvik
Date: 12/7/2007 10:46:32 AM
ashish_postgre@yahoo.co.in (Ashish Karalkar) wrote in news:33481.2408.qm@web94314.mail.in2.yahoo.com: > > > "A. Kretschmer" <andreas.kretschmer@schollglas.com> wrote: am Wed, dem 05.12.2007, um 10:24:04 +0000 mailte Ashish Karalkar folgendes: >> Hello List member, >> >> Iha a table containing two columns x and y . for single value of x there are >> multiple values in y e.g >> >> X Y >> ------------ >> 1 ABC >> 2 PQR >> 3 XYZ >> 4 LMN >> 1 LMN >> 2 XYZ >> >> I want a query that will give me following output >> >> 1 ABC:LMN >> 2 PQR:XYZ >> 3 XYZ >> 4 LMN >> > > You need a new aggregate-function. A solution for a similar problem (but > with comma instead :) can you find here: > http://www.zigo.dhs.org/postgresql/#comma_aggregate > > Thanks Andreas for your replay. > But i don't have an option two send argument to the store proc nither do i know how many multiple records are there for a single X. I want result for all rows of table. > > I dont thnink that function will give desired output. I think you will understand the consept if you really read about aggregates and how to create them. From other posts it also seems that the job can be simplified by using existing aggregates and functions.