表/连接/一张表和另一张表的聚合字段连接
用Northwind中的表:
SELECT CustomersID,CompanyName,ContactName,Address,
City,Region,Phone,a.orderCount
FROM dbo.CustomersInfo,(SELECT CustomerID,SUM(OrderAmount) AS orderCount FROM dbo.Orders GROUP BY CustomerID) as a
WHERE CustomersInfo.CustomersID=a.CustomerID
主要把select的结果集重新命名a
这样就可以调用a的字段了
原文链接:https://www.f2er.com/javaschema/287415.html