I have two questions left for an assignment and I can not figure them out.
Here they are:
List the territory_id and the territory_name of all territories where end tables have been sold.
List the total sales for each sales territory by salesperson.
Any advise would be greatly appreciated.
I dont even know how to start these...I have completed the rest of my assignment...The problem with the first one is there is not a territory_id or territory_name under the order table so Im supposed to use a bunch of different tables...
I believe I am supposed to look at the order_line_t table then see if there is any end tables sold...but my problem comes when There is no territory_id in order_line_t or Order_t...Its only in does_business_in_t or territory_t.
Your question is asking you to learn about using JOINS in order to connect data in different tables in order to satisfy business related questions.
Every author has an ID in their row in the table, this is their unique identifier, it is special to them and only them. This is a Primary Key. Also in their row is a column called publisher_ref, this is the ID of their publisher. we dont store all the information about the publisher in the Authors table, we have the publishers table for that. Lots of authors will share the same publisher so the publisher_ref will be seen many times in the authors table. This is a foreign key - it is a link to the primary key of another table
Every publisher has an ID in their row in the table, this is their unique identifier, it is special to them and only them. This is the primary key of the publishers table and is in a relationship with the authors table via the relationship of the publishers primary key to the authors foreign key.
We can get information about an author by writing a script that selects information from the authors table:
If we want to gather information about authors and publisher we have to JOIN the two tables:
It is wholly possible to build a string of JOINS to connect information from lots of tables, simply by identifying the relationships and repeating the INNER JOIN line so if there was a titles table and a vendors table we could get information about the books an author has written, who published them, what they were called and where they were sold with a query like:
Hope this and the other answers have helped to explain the way you need to answer your assignment.
You may like to join to other tables to get more info:
answered Apr 22, 2010 at 12:17 AM