I am trying to implement one query in Couchbase by using the web interface of couchbase and also using curl to measure the timing performance. I used this query, but it shows me null result. I used the similar query in MySQL and it is working fine
SELECT avg(`EB1.PYG.R.LWDP.001.INST`) as value_avg1,
avg(`EB1.PYG.T.TOP.001.INST`) as value_avg2, AVG(`EB1.PYG.R.LWDP.001.INST`)
+ ((5.67E-8) * (POWER(AVG(`EB1.PYG.T.TOP.001.INST`) + 273.14, 4))) as
final_value FROM EBM_DAS1 WHERE META().id >= "1456411717000000" AND
META().id <= "1456412317000000";
The output of above query was Null, so I try to make a simple query, e.g
SELECT avg(`EB1.PYG.R.LWDP.001.INST`) as Average FROM EBM_DAS1 WHERE
META().id >= "1456411717000000" AND META().id <= "1456412317000000";
and it also result in Null, but If I use the same query to fetch the data, it fetches and returns the data.
SELECT (`EB1.PYG.R.LWDP.001.INST`) FROM EBM_DAS1 WHERE META().id
>= "1456411717000000" AND META().id <= "1456412317000000";
If I just use this query to fetch data, it gives me data and works properly but it doesn’t calculate and return average value
and the data it returns looks like
[
{
"EB1.PYG.R.LWDP.001.INST": "-84.23"
},
{
"EB1.PYG.R.LWDP.001.INST": "-83.23"
},
{
"EB1.PYG.R.LWDP.001.INST": "-82.53"
},
...
...
...
...
{
"EB1.PYG.R.LWDP.001.INST": "-80.1"
}
]
I also tried with curl command to fetch the data and curl command is as follow.
curl -v http://localhost:8093/query/service -d 'statement=SELECT
avg(LENGTH(`EB1.PYG.R.LWDP.001.INST`)) as value_avg1,
avg(LENGTH(`EB1.PYG.T.TOP.001.INST`)) as value_avg2,
AVG(LENGTH(`EB1.PYG.R.LWDP.001.INST`)) + ((5.67E-8) *
(POWER(AVG(`EB1.PYG.T.TOP.001.INST`) + 273.14, 4))) as final_value
FROM EBM_DAS1 WHERE META().id >= "1456411717000000" AND
META().id <= "1456412317000000"&pretty=false';
and it result in
{
"requestID": "b6d49d1a-6016-4444-914c-4df990e43d9f",
"errors": [{"code":3000,"msg":"syntax error - at ("}],
"status": "fatal",
"metrics": {"elapsedTime": "625.736µs","executionTime": "586.512µs",
"resultCount": 0,"resultSize": 0,"errorCount": 1}
}
I run successfully similiar query in MySQL to obtain the desire results.
Can someone guide me why I am getting ‘null’ results and curl is also not working. I am beginner to database technology and specially to couchbase. I try my best to figure out the problem but unable to find. I would be grateful. Thanks