How to access array element in pgsql after array_agg

From: Condor <condor(at)stz-bg(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to access array element in pgsql after array_agg
Date: 2014-06-17 18:22:42
Message-ID: 5bc9c7090f9638f9ca98f36d43472bbb@stz-bg.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hello,

I wanna ask how I can access array element in array_agg ?

I do select array_agg(ids) from x;
in ids I have int and result is :

array_agg
-------------
{3843,2,3543,33}

I want to access one element or first one direct in sql query like:

select array_agg(ids)[1] from x;

and to receive int value 2

Any hints how I can do it ?

And also for performance did that is good I to do it in SQL or I should
do it in language that I use ? The result in query will return about 2,
3 million rows.

Thank you,

Cheers,
Hristo S.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message François Beausoleil 2014-06-17 19:44:37 Re: How to access array element in pgsql after array_agg
Previous Message Ziggy Skalski 2014-06-17 18:16:38 Re: pg_restore: custom archiver unexpected end of file , ERROR: missing data for column