Ive docs as below with created date in my bucket
{
"id": "1234",
"created": "2020-03-11T17:28:49.597838+11:00"
}
{
"id": "9872",
"created": "2020-02-04T17:28:49.597838+11:00"
}
{
"id": "9892",
"created": "2020-02-12T17:28:49.597838+11:00"
}
Now, I need to Select count of records by created (previousMonth and currentMonth).
Expected result
{
'prevousMonth': 1,
'currentMonth': 2
}
Currently , Im using two separate queries and it works. How to use these in subquery to get a result as above.
SELECT COUNT (d.id) AS previous
FROM `default` AS d
WHERE d.created >= '2020-02-01'
AND d.created < '2020-03-01'
SELECT COUNT (d.id) AS current
FROM `default` AS d
WHERE d.created >= '2020-03-01'
AND d.created < '2020-04-01'