我有2个查询
@Query("SELECT * FROM basket_items")
LiveData<List<BasketItem>> getAll();
@Query("SELECT SUM(count*amount) FROM basket_items")
LiveData<Double> totalSum();
如何通过一个查询选择此数据?
我创建了模型
public class BasketItemWithTotal {
private List<BasketItem> basketItems;
private Double total;
}
并创建了查询:
@Query("SELECT *, SUM(count*amount) as total FROM basket_items")
LiveData<BasketItemWithTotal> getAllWithTotal();
但它无效