pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Advice returning data as an array
2+ messages / 2 participants
[nested] [flat]

* Advice returning data as an array
@ 2009-08-20 12:07 George Woodring <george.woodring@iglass.net>
  2009-08-26 18:20 ` Re: Advice returning data as an array Erik Jones <ejones@engineyard.com>
  0 siblings, 1 reply; 2+ messages in thread

From: George Woodring @ 2009-08-20 12:07 UTC (permalink / raw)
  To: pgsql-sql

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?

Thanks,
Woody

-- 
iGLASS Networks
www.iglass.net

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Advice returning data as an array
  2009-08-20 12:07 Advice returning data as an array George Woodring <george.woodring@iglass.net>
@ 2009-08-26 18:20 ` Erik Jones <ejones@engineyard.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Erik Jones @ 2009-08-26 18:20 UTC (permalink / raw)
  To: George Woodring <george.woodring@iglass.net>; +Cc: pgsql-sql


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








^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2009-08-26 18:20 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-08-20 12:07 Advice returning data as an array George Woodring <george.woodring@iglass.net>
2009-08-26 18:20 ` Erik Jones <ejones@engineyard.com>

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