Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Do I need WHERE clause here?

Author  Topic 

rv498
Yak Posting Veteran

60 Posts

Posted - 2014-03-18 : 17:02:01
List the amount of the total sales of reseller sales by business type.
-- First find the business type to determine you have them all. Then create your query.
-- 3 Rows

I'm not sure how to translate 'First find the business type' to SQL code.

SELECT SUM(ROUND(S.[OrderQuantity] * S.UnitPrice, 2)) AS TotalSales
FROM dbo.DimReseller AS R
INNER JOIN dbo.FactResellerSales AS S
ON R.ResellerKey = S.ResellerKey

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-03-18 : 17:05:52
They want you to use a GROUP BY with business type.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-03-18 : 17:06:35
I think they mean that you need to show the total sales for each business type. So you need to add the business type as a column in the select list. When you do that, it will also require that you add that column in the GROUP BY clause.
Go to Top of Page

rv498
Yak Posting Veteran

60 Posts

Posted - 2014-03-18 : 21:47:47
SELECT R.BusinessType, SUM(R.AnnualSales) AS TotalSales
FROM dbo.DimReseller AS R
GROUP BY R.BusinessType

I believe this is correct.
Go to Top of Page
   

- Advertisement -