Re: postgresql query

From: AI Rumman <rummandba(at)gmail(dot)com>
To: Jashaswee <sweet(dot)rinky72(at)gmail(dot)com>
Cc: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: postgresql query
Date: 2013-06-19 18:43:54
Message-ID: CAGoODpes++CVid7H6ub5M+vu0TKdJQQfbokiew5G8hCXwG35iA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Which version of Postgresql are you using?
However, you may use string_agg like below if its available in your version:

\d t1
Table "public.t1"
Column | Type | Modifiers
--------+---------+-----------
i | integer |
amt | integer |

select * from t1;
i | amt
---+-----
1 | 20
1 | 30
2 | 30
(3 rows)

select i, string_agg(amt::text,',') as c from t1 group by i;;
i | c
---+-------
1 | 20,30
2 | 30
(2 rows)

Have a good day.

On Wed, Jun 19, 2013 at 6:51 AM, Jashaswee <sweet(dot)rinky72(at)gmail(dot)com> wrote:

> I have numeric values in a numeric column.the column has two parts.i want
> to
> split in 2 differnet column .
> The column value looks like this:
>
> Quantity
> 2000
> -1000
>
> both the quantity values are of a same product.but i want these in a
> single
> line.
> so what i want is a result set that looks like:
> In quantity Out quantity
> ----------- ------------
> 2000 -1000
>
> how can i get this in a select statement ?
>
>
>
> --
> View this message in context:
> http://postgresql.1045698.n5.nabble.com/postgresql-query-tp5759846.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Victor Yegorov 2013-06-19 18:56:32 Re: postgresql query
Previous Message Peter Eisentraut 2013-06-19 13:57:33 Re: pgxs question - linking c-functions to external libraries