couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mauro Fagnoni <mauro.fagn...@gmail.com>
Subject convert data query into map/reduce function
Date Mon, 16 May 2011 14:52:22 GMT
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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message