Please help me check my answers for the following: In all of the following, the
ID: 3918768 • Letter: P
Question
Please help me check my answers for the following:
In all of the following, the common attribute between the two tables will have the same name, so that you know what to join on. Use table aliases.
- Write a SELECT from the vendors table INNER JOINed to the invoices table. Return all columns using *. (Hint: this will give you 114 rows.)
- Write a SELECT from the invoice_line_items table INNER JOINed to the general_ledger_accounts table. Return all columns using *. (Hint: this will give you 118 rows.)
- Write a SELECT from the customers table INNER JOINed to the orders table. Return all columns using *. (Hint: this will give you 46 rows.)
- Write a SELECT from the employees table INNER JOINed to the departments table. Return all columns using *. (Hint: this will give you 7 rows.)
- Write a SELECT from the employees table INNER JOINed to the projects table. Return all columns using *. (Hint: this will give you 7 rows.)
- Write a SELECT from the invoices table INNER JOINed to the invoice_line_items table. Return all columns using *. (Hint: this will give you 118 rows.)
- Write a SELECT from the order_details table INNER JOINed to the items table. Return all columns using *. (Hint: this will give you 67 rows.)
- Write a SELECT from the orders table INNER JOINed to the order_details table. Return all columns using *. (Hint: this will give you 67 rows.)
- Write a SELECT from the invoices table INNER JOINed to the terms table. Return all columns using *. (Hint: this will give you 114 rows.)
Explanation / Answer
Q1) Write a SELECT from the vendors table INNER JOINed to the invoices table. Return all columns using *
SELECT * FROM VENDORS INNER JOIN INVOICES ON VENDOR.VENDOR_ID = INVOICES.VENDOR_ID;
Q2) Write a SELECT from the invoice_line_items table INNER JOINed to the general_ledger_accounts table
SELECT * FROM invoice_line_items INNER JOIN general_ledger_accounts ON invoice_line_items.LINE_ITEM_ID = general_ledger_accounts.LINE_ITEM_ID;
Q3) Write a SELECT from the customers table INNER JOINed to the orders table. Return all columns using *. (Hint: this will give you 46 rows.)
SELECT * FROM CUSTOMERS INNER JOIN ORDERS ON CUSTOMER.CUST_ID = ORDERS.CUST_ID;
Q4) Write a SELECT from the employees table INNER JOINed to the departments table. Return all columns using *. (Hint: this will give you 7 rows.)
SELECT * FROM EMPLOYEES INNER JOIN DEPARTMENTS ON EMPLOYEE.EMPID = DEPARTMENT.EMPID;
Q5) Write a SELECT from the employees table INNER JOINed to the projects table. Return all columns using *. (Hint: this will give you 7 rows.)
SELECT * FROM EMPLOYEES INNER JOIN PROJECTS ON EMPLOYEE.EMPID = PROJECTS.EMPID;
Q6) Write a SELECT from the invoices table INNER JOINed to the invoice_line_items table. Return all columns using *.
SELECT * FROM INVOICES INNER JOIN invoice_line_items ON INVOICES.INVOICE_ID = invoice_line_items.INVOICE_ID;
Please let me know in case of any clarifications required. Thanks!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.