Backendless Support
 
Answered

¿How can I retrieve a data list from a database from an specific column using codeless?

I want to do a progress circle using data from a table stored in Backendless.

using codeless all I need to do is create an api to sum all the values from the "percentage" column selecting only the to do's marked as done in the "status" column

Can you guide me please?

Best Answer
photo

Or you can use aggregate function available in Backendless and then your logic would look next way:

https://image.ibb.co/gFmAK8/Selection_332.png

More about aggregate function read here:

https://backendless.com/introducing-aggregate-functions-average-count-sum-max-and-min/

https://backendless.com/docs/rest/doc.html#aggregate-functions

Leave a Comment

Comments (11)

photo
1

Hi Carlos,

We'd be happy to help. Would you be able to provide an example of a response (as JSON) the API should return? I know this is backwards, but, by doing so, it would be easier for us know exactly what's you're looking to get.

Regards,

Mark

photo
1

Hi Mark! :)

The final result (response) should be a number, but maybe I am understanding wrongly, do you mean the first result from the table?

If so, ( it is a demo table ) here it is:

[

{

"___jsonclass": "tareas_programadas",

"tarea": "titulo de tarea 3",

"estatus": "Si",

"created": 1531328021569,

"pieza": "001",

"___class": "tareas_programadas",

"programa": "001",

"porcentaje": "2",

"ownerId": null,

"puntos": "2",

"updated": 1531328107782,

"objectId": "43443B29-D240-0B46-FF41-41A46B59E600",

"vence": 1534309200000

},

{

"___jsonclass": "tareas_programadas",

"tarea": "titulo de tarea 2",

"estatus": "Si",

"created": 1531231736187,

"pieza": "001",

"___class": "tareas_programadas",

"programa": "001",

"porcentaje": "2",

"ownerId": null,

"puntos": "1",

"updated": 1531327616268,

"objectId": "75A2F3A2-AD1B-63A0-FF78-D64011906700",

"vence": 1531630800000

}

]

Or I might not explained myself clearly (sorry for my bad english)

but from this object, I want to extract the values from column "porcentaje", add the values and return the number as the api result

photo
2

Hi Carlos,

if I correctly understand you, you want something like I did on my screenshot:

https://image.ibb.co/d0D4e8/Selection_328.png

For each item of your objects list, which has field `estatus` equal to `Si`, I sum `porcentaje` column value and return the sum. Please check it.

photo
2

Or you can use aggregate function available in Backendless and then your logic would look next way:

https://image.ibb.co/gFmAK8/Selection_332.png

More about aggregate function read here:

https://backendless.com/introducing-aggregate-functions-average-count-sum-max-and-min/

https://backendless.com/docs/rest/doc.html#aggregate-functions

photo
1

WOW!!! Great answers Stanislav! Specially the second one, that is exactly what I needed, now I understand so much better how to use this great tool

photo
1

There is another use for Load Table Objects' Properties besides aggregate functions?

photo
1

Yes, this prop also references object properties which should be returned with every object. So you can ask Backendless to return only some set of fields for each record.

photo
1

like a Select in a SQL query?

photo
1

Similar, we support a subset of SQL, specifically the part that goes after "WHERE" in an SQL statement, that's why we call it the "whereClause". You can read about it here: https://backendless.com/docs/rest/doc.html#data_search_with_where_clause

photo
photo
1

Glad to help! Happy coding!

photo
1

Thank you very much!

photo