how to query against nested hstore data type - Mailing list pgsql-general

From Huang, Suya
Subject how to query against nested hstore data type
Date
Msg-id D83E55F5F4D99B4A9B4C4E259E6227CD014F78D1@AUX1EXC02.apac.experian.local
Whole thread Raw
Responses Re: how to query against nested hstore data type  (Peter Geoghegan <peter.geoghegan86@gmail.com>)
Re: how to query against nested hstore data type  (Adrian Klaver <adrian.klaver@aklaver.com>)
Re: how to query against nested hstore data type  (John R Pierce <pierce@hogranch.com>)
List pgsql-general

Hi,

 

It’s my test DB, the version is PostgreSQL 9.4beta2. I’m testing with nested hstore feature.

 

testdb=# \d+ test

                         Table "public.test"

Column |  Type  | Modifiers | Storage  | Stats target | Description

--------+--------+-----------+----------+--------------+-------------

id     | text   |           | extended |              |

stats  | hstore |           | extended |              |

 

 

testdb=# select * from test;

      id       |                                                                                         stats                                                

---------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

2b8ea99d60b30 | "www.ask.com"=>"{visits=>2.11221003268,pages=>4.22442006537,duration=>197980.836904}", "www.strawberrynet.com"=>"{visits=>2.11221003268,pages=>4.22442006537,duration=>197980.836904}"

(1 row)

 

 

testdb=# select (each(channel)).key,(each(channel)).value from visits;

          key          |                                value

-----------------------+----------------------------------------------------------------------

www.ask.com           | {visits=>2.11221003268,pages=>4.22442006537,duration=>197980.836904}

www.strawberrynet.com | {visits=>2.11221003268,pages=>4.22442006537,duration=>197980.836904}

(2 rows)

 

The question is how can I get visits/pages/duration separately from the value column so that I can do a sum on those metrics individually.

 

 

Thank you!

Suya

 

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: How to insert either a value or the column default?
Next
From: Peter Geoghegan
Date:
Subject: Re: how to query against nested hstore data type