SQL Server查询错误WHERE条件 GROUP BY列名(S) ORDER BY列名(S);
问题描述:
select Products.prodname,
sum(billdetail.Qty) as qty,
BillDetail.rate,
sum(billdetail.amt) as Amt
from billdetail
inner join products on products.prodid = billdetail.prodid
inner join category on category.catid = products.catid
group by prodname, rate
where CatName = "Chicken";
答
-- Group by Come After Where Clause
select Products.prodname, sum(billdetail.Qty) as qty,BillDetail.rate,
sum(billdetail.amt) as Amt from billdetail
inner join products
on products.prodid = billdetail.prodid
inner join category
on category.catid = products.catid
where CatName = 'Chicken'
group by prodname,rate
这里是组 SELECT列名(S) 的语法FROM table_name的 –
如果在问题中包含错误文本,它将帮助我们确定错误的原因。 –
欢迎来到Stack Overflow。我们将帮助您解决编程问题,但您首先希望自己动手,而您的问题不会显示。这个问题可能会被删除,因为脱离主题或不清楚。请阅读https://*.com/help/how-to-ask以获取更多信息 – Mikkel