I have a class entity as below
@Entity public class Task { private String name; private Integer ParentId; private Integer userId; @Ignore
Create a sub class of Task suppose
public class TaskDisplayModel extends Task{ @Ignore private transient int noOfSubTask; }
Then your query will be
@Query("SELECT *,(SELECT count(*) FROM Task b WHERE a._id = b.ParentId ) AS noOfSubTask FROM Task a ") LiveData> getTaskList();