vb.net和访问数据库问题

时间:2017-11-10 06:48:36

标签: sql vb.net ms-access

我收到了这个错误:

  

您的查询不包含指定的表达式作为一部分   聚合函数

当我试图执行此操作时:

SELECT DISTINCT invoice_details.item,
SUM((invoice_details.cartoons * products.punits) + invoice_details.units) as units,
SUM(invoice_details.total) as total
FROM invoice_details, products, invoices
WHERE invoices.invoice_id = invoice_details.invoice_id
and products.pname = invoice_details.item
and format(invoices.create_date, "d/mm/yyyy") = DATE()

1 个答案:

答案 0 :(得分:1)

Sum是一个聚合函数,因此必须在Group by子句中使用查询中调用的所有Other字段。这可能会解决问题。