为了账号安全,请及时绑定邮箱和手机立即绑定

关于sql server查询的问题

关于sql server查询的问题

白猪掌柜的 2018-12-07 04:06:54
DECLARE @City NVARCHAR(20); SET @City='London'; SELECT C.CustomerID,COUNT(O.OrderID) AS NumOrders FROM dbo.Customers AS C LEFT JOIN dbo.Orders AS O ON C.CustomerID=O.CustomerID WHERE C.City=@City GROUP BY C.CustomerID HAVING COUNT(O.OrderID)>5 ORDER BY NumOrders SELECT C.CustomerID,COUNT(O.OrderID) AS NumOrders FROM dbo.Customers AS C LEFT JOIN dbo.Orders AS O ON C.CustomerID=O.CustomerID WHERE C.City='London' GROUP BY C.CustomerID HAVING COUNT(O.OrderID)>5 ORDER BY NumOrders   为什么使用变量之后,第一个快过第二个, 第一个的执行开销为43% 第二个的执行开销为57%
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 507 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信