Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id B92AB634125 for ; Wed, 26 Aug 2009 15:40:00 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 74975-02-5 for ; Wed, 26 Aug 2009 18:39:46 +0000 (UTC) X-Greylist: delayed 00:05:42.616777 by SQLgrey-1.7.6 Received: from smtp136.iad.emailsrvr.com (smtp136.iad.emailsrvr.com [207.97.245.136]) by mail.postgresql.org (Postfix) with ESMTP id AEAFB636B2F for ; Wed, 26 Aug 2009 15:26:24 -0300 (ADT) Received: from relay23.relay.iad.mlsrvr.com (localhost [127.0.0.1]) by relay23.relay.iad.mlsrvr.com (SMTP Server) with ESMTP id 9FA7A1B41EF; Wed, 26 Aug 2009 14:20:40 -0400 (EDT) Received: by relay23.relay.iad.mlsrvr.com (Authenticated sender: ejones-AT-engineyard.com) with ESMTPSA id 4D8E11B4026; Wed, 26 Aug 2009 14:20:40 -0400 (EDT) Cc: pgsql-sql@postgresql.org Message-Id: <3EB27E36-4935-4DDA-B365-53D72B7226AF@engineyard.com> From: Erik Jones To: George Woodring In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: Advice returning data as an array Date: Wed, 26 Aug 2009 11:20:39 -0700 References: X-Mailer: Apple Mail (2.936) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200908/134 X-Sequence-Number: 33043 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