以下SELECT语句产生此结果
SELECT ProductID, SUM(Quantity) AS Quantity
FROM Production.ProductInventory
WHERE ProductID NOT IN (1001)
GROUP BY ProductID;
Run Code Online (Sandbox Code Playgroud)
为什么下面编辑的SELECT语句不会产生任何结果?
SELECT ProductID, SUM(Quantity) AS Quantity
FROM Production.ProductInventory
WHERE Quantity >= 1800
GROUP BY ProductID;
Run Code Online (Sandbox Code Playgroud)
使用AdventureWorks数据库,我收到了一个问题:" 列出订单客户名称,订单状态,订购日期,订单上的商品数量,以及订单中商品数量大于300的订购平均数量 ".但是,我的下面的SELECT语句没有返回任何结果......我做错了什么?
SELECT scpii.LastName + ', ' + scpii.FirstName AS 'Customer Name', ssoh.Status AS 'Order Status', ssoh.OrderDate AS 'Date Ordered', SUM (ssod.OrderQty) AS 'Count of Items', AVG (ssod.OrderQty) AS 'Average Quantity'
FROM Sales.CustomerPII scpii
INNER JOIN Sales.SalesOrderHeader ssoh
ON ssoh.CustomerID = scpii.CustomerID
INNER JOIN Sales.SalesOrderDetail ssod
ON ssod.SalesOrderID = ssoh.SalesOrderID
GROUP BY scpii.LastName, scpii.FirstName, ssoh.Status, ssoh.OrderDate, ssod.OrderQty
HAVING SUM(ssod.OrderQty) > 300;
Run Code Online (Sandbox Code Playgroud) Is it possible to highlight rows where the employee Number is the same, but has more than one Job Name and at least one of those Job Names has to contain the word "Manager"? So in the case below, The employee number 12 rows would be highlighted because it has more than one Job Name and one of those Job names contains the word "Manager". Would something like this be done in VBA, Conditional Formatting, Formulas, or any other methods?