I'm running the following SQL command as shown below. This command looks at all row between the respective start and date and find the MAX of the TotalCPULoadMIPS field for each day.
If i remove the "@timestamp" the SQL runs properly. The command will not accept more than one field. It only accepts one field as long as we use an arithmetic function.
POST /_sql?format=csv
{"query":"SELECT \"@timestamp\", MAX(TotalCPULoadMIPS) AS PeakMips FROM testwebsphere WHERE \"@timestamp\" BETWEEN CAST('2019-03-01' AS DATE) AND CAST('2019-04-30' AS DATE) GROUP BY CAST (\"@timestamp\" AS DATE) " }
The error we get is shown below:
{
"error": {
"root_cause": [
{
"type": "verification_exception",
"reason": "Found 1 problem(s)\nline 1:9: Cannot use non-grouped column [@timestamp], expected [CAST (\"@timestamp\" AS DATE)]"
}
],
"type": "verification_exception",
"reason": "Found 1 problem(s)\nline 1:9: Cannot use non-grouped column [@timestamp], expected [CAST (\"@timestamp\" AS DATE)]"
},
"status": 400
}
How can i add another field in the SELECT statement? What is the proper syntax? Why is this not accepted syntax?
Also tried:
POST /_sql?format=csv
{"query":"SELECT CAST (\"@timestamp\" AS DATE), MAX(TotalCPULoadMIPS) AS PeakMips FROM testwebsphere WHERE \"@timestamp\" BETWEEN CAST('2019-03-01' AS DATE) AND CAST('2019-04-30' AS DATE) GROUP BY CAST (\"@timestamp\" AS DATE) " }
Got this error:
{
"error": {
"root_cause": [
{
"type": "folding_exception",
"reason": "line 1:9: Cannot find grouping for 'CAST (\"@timestamp\" AS DATE)'"
}
],
"type": "folding_exception",
"reason": "line 1:9: Cannot find grouping for 'CAST (\"@timestamp\" AS DATE)'"
},
"status": 400
}