我编写的查询是跳过空的lists。我的尝试:SELECT lists.id, name, COUNT(items_x_lists.listId) AS count, SUM(items_x_lists.purchaseditems_x_lists.listIdSELECT listId AS id,lists.name, COUNT(listId) AS count, SUM(两个查询相同的结果)
当我添加一个左连接来获取外部表的计数时,它乘以我的其他左连接表的和值与计数,我也不能在这里使用distinct sum,因为两个值可以是相同的: SELECT c.id as company_id,SUM(ct.amount) as total_billed, count(l.id) as load_countLEFT
我有个桌子主人Jhon product1
另一表:产品克里斯1 7
select Owners.owner, count(distinct Owners.product) as NumberOfProducts, sum(Product.QuantitySold) as QuantitySold from Owners O, Products P
group by