incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Matheis <matheis.ste...@googlemail.com>
Subject Re: convert data query into map/reduce function
Date Mon, 16 May 2011 14:56:41 GMT
Mauro,

i think a short example would be really helpful .. especially related
to your data-structure .. and the expected behaviour. do you already
have an reduce function, but it does not work like you'd have it to?

Regards
Stefan

On Mon, May 16, 2011 at 4:52 PM, Mauro Fagnoni <mauro.fagnoni@gmail.com> wrote:
> Hi all, i've to convert this sql query into couchdb  function but i've some
> problem with reduce function. Some one can help me??
> Many thanks and best regards
>
> *
> SQL QUERY:*
>
> SELECT
>             L_RETURNFLAG,
>             L_LINESTATUS,
>     sum(L_QUANTITY)as sum_qty,
>     sum(L_EXTENDEDPRICE) as sum_base_price,
>     sum(L_EXTENDEDPRICE*(1-L_DISCOUNT)) as sum_disc_price,
>     sum(L_EXTENDEDPRICE*(1-L_DISCOUNT)*(1+L_TAX)) as sum_charge,
>     avg(L_QUANTITY) as avg_qty, avg(L_EXTENDEDPRICE) as avg_price,
>     avg(L_DISCOUNT) as avg_disc,count(*) as count_order
> FROM
>             LINEITEM
> WHERE
>             L_SHIPDATE <= date '1998-12-01' - interval '90' day"
>
> GROUP BY
>            L_RETURNFLAG,
>            L_LINESTATUS
> ORDER BY
>            L_RETURNFLAG,
>            L_LINESTATUS
>
>
> couchdb function by curl
>
> curl -X POST http://127.0.0.1:5984/testdb/_temp_view -H "Content-Type:
> application/json" -d'{"map":"function("doc"){if(doc.l_shipdate <=
> 1998-09-01) emit(doc)}" "reduce":"function{if(.....)}}
>
>
> --
> -----------------------------------------------
> [-------WHOAMI------] Mauro Fagnoni
> [----------ICQ#---------] 279572903
> [--------MSNID--------] maurofagnoni@yahoo.it
> [--YAHOOMSNID--] maurofagnoni@gmail.com
> [--GOOGLETALK--] mauro.fagnoni@gmail.com
> [-GOOGLEWAVE-] mauro.fagnoni@googlewave.com
> [------JABBER-------] mauro.fagnoni@gmail.com
> [------SKYPE--------] mauro.fagnoni
> [-----LinuxUser#----] 346345
> [----------Blog---------] http://kingmauro.wordpress.com
> -----------------------------------------------
>

Mime
View raw message