From: Erik Jones <ejones@engineyard.com>
To: George Woodring <george.woodring@iglass.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Advice returning data as an array
Date: Wed, 26 Aug 2009 11:20:39 -0700
Message-ID: <3EB27E36-4935-4DDA-B365-53D72B7226AF@engineyard.com> (raw)
In-Reply-To: <cfbfcf160908200507q422601c2r3950f5db8a102587@mail.gmail.com>
References: <cfbfcf160908200507q422601c2r3950f5db8a102587@mail.gmail.com>
On Aug 20, 2009, at 5:07 AM, George Woodring wrote:
> I have the following query that works the way I need:
>
> SELECT '20090812' AS date, sum(in_oct) AS bytes, sum(in_pkt) AS
> pkts, 'appl' AS name, ARRAY['appl'] AS fields, CAST((LEAST(src_port,
> dst_port)) AS varchar) as fieldVal FROM flow_history.flows_20090812
> GROUP BY fieldVal ORDER BY bytes DESC LIMIT 20;
>
> My issue is that I need to get the fieldVal to return as an array
> and be fieldVal[1]. Any suggestions?
The manual has everything you should need: http://www.postgresql.org/docs/8.4/interactive/arrays.html#ARRAYS-IO
What would help us help you past that is if you show what you have
already tried so we know where you need correction/help.
Erik Jones, Database Administrator
Engine Yard
Support, Scalability, Reliability
866.518.9273 x 260
Location: US/Pacific
IRC: mage2k
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ejones@engineyard.com, george.woodring@iglass.net
Subject: Re: Advice returning data as an array
In-Reply-To: <3EB27E36-4935-4DDA-B365-53D72B7226AF@engineyard.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox