October 20, 2010 at 7:37 pm
View the highest 100 different amounts that were donated. So write a query to list the 100 amounts. 1 SELECT *
2 FROM (SELECT Customer.CustomerID, SUM(TotalDue) AS TotalGiven,
3
4 FROM Customer
5 JOIN SalesORder
6 ON Customer.CustomerID = SalesOrder.CustomerID
7 GROUP BY Customer.CustomerID) AS DonationsToFilter
8 WHERE FilterCriteria <= 100
In order of complete the query, you have to insert a Transact-SQL clause in line 3.
What would be answer to the above query from the below?
A) DENSE_RANK() OVER (ORDER BY SUM(TotalDue) DESC)
B) NTILE(100) OVER (ORDER BY SUM(TotalDue) DESC)
October 20, 2010 at 9:15 pm
I assume that you've tried each of these? What did you find out when you tested them?
BTW, what college do you go to? What is your professor's name?
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
October 20, 2010 at 9:25 pm
I dont have a SQL 2005/2008 to test. Could you please tell me where would I test it (online)?
October 20, 2010 at 10:13 pm
SATISD9X (10/20/2010)
I dont have a SQL 2005/2008 to test. Could you please tell me where would I test it (online)?
No excuse... here's a free copy for you to install and test with.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply