December 14, 2009 at 2:18 am
Hi guys,
Can someone help please??
I have two tables (a) Store containing name of store/city, date & sales (b) region & name of store
My goal is to pull a total sales from region. However, I can only seem to pull the separate cities.
Can someone have a look at my T-SQL and advise how I should amend this?
Thanks,
L
•select geog.store_name,geog.region_name, sum(sales)
•AS Total_sales
•from store_info inner join geog
•On geog.store_name = store_info.store_name
•Where geog.region_name = 'west'
•group by store_info.store_name, geog.store_name,geog.region_name
•Order by sum(sales) desc
December 14, 2009 at 3:28 am
Please read this article on how to post query,
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Is this what you need?
select geog.region_name, sum(sales) AS Total_sales
from store_info inner join geog
On geog.store_name = store_info.store_name
Where geog.region_name = 'west'
group by geog.region_name
Order by sum(sales) desc
---------------------------------------------------------------------------------
December 14, 2009 at 6:34 am
Hi Nabha,
Thanks for the reply. Yes, your amendment is what I was looking for, it was obvious to me once I looked at your code.
I'll read up on the link you provided.
Thanks again.
L
December 14, 2009 at 10:34 pm
Nabha (12/14/2009)
Please read this article on how to post query,http://www.sqlservercentral.com/articles/Best+Practices/61537/
Is this what you need?
select geog.region_name, sum(sales) AS Total_sales
from store_info inner join geog
On geog.store_name = store_info.store_name
Where geog.region_name = 'west'
group by geog.region_name
Order by sum(sales) desc
Nice.
--Jeff Moden
Change is inevitable... Change for the better is not.
December 15, 2009 at 8:10 am
Thanks Jeff 🙂
---------------------------------------------------------------------------------
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply