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.
| Author |
Topic |
|
mameha1977
Starting Member
3 Posts |
Posted - 2012-10-19 : 06:11:45
|
| I wish to find out the total sales per industry using SQL.Tables:- Sales- Customer- IndustryThe tables are linked as follows:- Sales is linked to Customer by Customer_ID- Customer is linked to Industry by Industry_IDThe Sales table contains each sale (price + customer_id)The Customer table contains each customer (customer_id, industry_id)The Industry table contains each industry (industry_id, industry_name)I simply want to get the total sales for each Industry using SQL, with the result looking like this:INDUSTRY_NAME | TOTAL SALESIndustry4 9876Industry2 8889Industry3 7787Industry1 2898Can anyone work out the Query needed to select this data? |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2012-10-19 : 06:28:04
|
| SELECT industry_name, SUM( s.price) TotalSalesFROM Industy i JOIN Customer c ON i.indusrty_id = c.industry_idJOIN Sales s ON s.customer_id = c.dustomer_idGROUP BY industry_name--Chandu |
 |
|
|
mameha1977
Starting Member
3 Posts |
Posted - 2012-10-19 : 06:37:36
|
| Thanks bandi.I tried this:SELECT I.Industry, SUM(S.PRICE) AS TotalSalesFROM TEG_Industry IJOIN TEG_Customer C ON I.IndustryID = C.BranchJOIN TEG_sales S ON S.CompanyID = C.[Customer No]GROUP BY Industry;But it gives an error: "syntax error in FROM clause"Any idea what is wrong? |
 |
|
|
mameha1977
Starting Member
3 Posts |
Posted - 2012-10-19 : 06:40:59
|
| FYI: I am using MS Access |
 |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2012-10-19 : 07:14:53
|
quote: Originally posted by mameha1977 FYI: I am using MS Access
This is SQL Server forum. You can find solution in MS Access related Forums...--Chandu |
 |
|
|
|
|
|