How to get distinct row count in backendless

Hi All,
I am very new to backendless, I need to write query to get distinct row count from 3 tables.
Template:

TemplateId
TemplateName
TemplateDescription
FileName
Category;

CategoryId
UserId(FK)
CategoryNamr
categoryDescription
Task:

TaskId
CategoryId (many - many relationship)
TemplateId (one-many relationship)
TaskName
TaskDescription
TaskStatus
Now I need to get template name and number of tasks related to that template(unique count) and number of categories are related to template(unique count) something like this,
Template Name : Birthday Party
No.of tasks : 10
No.of Categories : 3
Template Name : Work Anniversary
No.of tasks : 20
No.of Categories : 5

The Sql query is:(It might not correct, please don’t mine)
select TemplateName,count(TaskId),count(CategoryId) from Task A, Template B where A.TemplateId= B.TemplateId Group by TemplateId,TemplateName.

Can anybody help me?
Thank you.

Hi Anusha,

Please, refer to the documentation: https://backendless.com/documentation/data/ios/data_basic_search.htm