I’ve read that you can write N1QL queries to use the order by clause
I have the following query / results:
cbq> select meta(`phonesys-reporting`).id from `phonesys-reporting` order by id asc;
{
"requestID": "0e0db41a-065f-44d6-b551-36e9d97137c4",
"signature": {
"id": "json"
},
"results": [
{
"id": "3"
},
{
"id": "4"
},
{
"id": "1"
},
{
"id": "2"
},
{
"id": "11"
}
],
"status": "success",
"metrics": {
"elapsedTime": "46.790912ms",
"executionTime": "46.71072ms",
"resultCount": 5,
"resultSize": 166,
"sortCount": 5
}
}
cbq>
As you can see, it’s ignoring the ASC keyword. So I tried this:
cbq> select meta(`phonesys-reporting`).id from `phonesys-reporting` order by TONUMBER(id) asc;
{
"requestID": "7a314958-240f-4be9-b989-baddf66a699a",
"signature": {
"id": "json"
},
"results": [
{
"id": "3"
},
{
"id": "2"
},
{
"id": "11"
},
{
"id": "4"
},
{
"id": "1"
}
],
"status": "success",
"metrics": {
"elapsedTime": "16.865178ms",
"executionTime": "16.798719ms",
"resultCount": 5,
"resultSize": 166,
"sortCount": 5
}
}
No errors, but I’m also not getting the desired results.
Any suggestions?