多表联接

来源:互联网 发布:百合手更新软件 编辑:程序博客网 时间:2024/05/21 19:33
select  C.custid,count (distinct O.orderid) AS 'ORDER_Num',SUM(qty) AS 'Product_Num'from Sales.Customers AS CJOIN Sales.Orders AS Oon C.custid = O.custidJOIN Sales.OrderDetails AS Don O.orderid = D.orderidwhere C.country = 'USA'group by C.custidorder by c.custid

原创粉丝点击