Results 1 to 3 of 3
  1. #1
    mameha1977 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2012
    Posts
    2

    Simepl query needed to JOIN three tables

    I wish to find out the total sales per industry using SQL.

    Tables:


    - Sales
    - Customer
    - Industry

    The tables are linked as follows:
    - Sales is linked to Customer by Customer_ID
    - Customer is linked to Industry by Industry_ID

    The 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 SALES
    Industry4 9876
    Industry2 8889
    Industry3 7787
    Industry1 2898

    Can anyone work out the Query needed to select this data?

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    Crossposted: http://forums.aspfree.com/microsoft-...es-536988.html

    See my response at the other forum.

  3. #3
    mameha1977 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2012
    Posts
    2
    resolved:

    SELECT TEG_Industry.Industry, Round(Sum(TEG_sales.PRICE), 0) AS TotalSales
    FROM (TEG_Industry INNER JOIN TEG_Customer ON TEG_Industry.IndustryID = TEG_Customer.Branch) INNER JOIN TEG_sales ON TEG_Customer.CustomerNo = TEG_sales.COMPANYID
    GROUP BY TEG_Industry.Industry
    ORDER BY Sum(TEG_sales.PRICE) DESC;

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Join multiple tables to one
    By b6677862 in forum Queries
    Replies: 1
    Last Post: 02-08-2012, 06:59 AM
  2. inner join query with three tables.
    By fabiobarreto10 in forum Queries
    Replies: 2
    Last Post: 01-30-2012, 07:34 PM
  3. Join 4 Tables in 1 Query
    By sandlucky in forum Queries
    Replies: 5
    Last Post: 06-12-2011, 06:28 PM
  4. Join for multiple tables?
    By Etownguy in forum Queries
    Replies: 3
    Last Post: 05-30-2011, 04:54 PM
  5. Join three or more tables in many to many link
    By elicoten in forum Database Design
    Replies: 3
    Last Post: 02-04-2010, 06:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums