SQL Server查询在哪里出错

时间:2017-09-16 07:38:28

标签: sql-server

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";

1 个答案:

答案 0 :(得分:1)

-- 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