Fix a Problem with Aliasing
We are aware of aliasing in SQL Server , but its impact is huge. You are presented with another grouped query that fails, this time because of an aliasing problem. As in the first exercise, you are provided with instructions on how to fix the query. 1. Clear the query window, type the following query, and execute it. SELECT OrgID, SUM(SaleOrders) AS SaleOrders FROM Sales.Orders WHERE SaleOrders > 20000 GROUP BY OrgID; The query was supposed to return only shippers for whom the SaleOrders value is greater than 20,000, but instead it returns an empty set. Try to identify the problem in the query. 2. Remember that the WHERE filtering clause is evaluated per row—not per group. The query filters individual orders with a freight value greater than 20,000, and there are none. To correct the query, you need to apply the filter per each shipper group—not per each ord