0% found this document useful (0 votes)
2 views

Lab6(Advanced Queries)

The document outlines the submission process for Lab 6 of the Comp1168 Database Management course, which involves advanced SQL queries. It provides specific tasks including INNER and OUTER JOIN queries, as well as a query involving multiple schemas. Students are required to use a template, include personal information, and submit their work as a PDF via D2L BrightSpace before the deadline.

Uploaded by

tfm23456
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lab6(Advanced Queries)

The document outlines the submission process for Lab 6 of the Comp1168 Database Management course, which involves advanced SQL queries. It provides specific tasks including INNER and OUTER JOIN queries, as well as a query involving multiple schemas. Students are required to use a template, include personal information, and submit their work as a PDF via D2L BrightSpace before the deadline.

Uploaded by

tfm23456
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Comp1168 Database Management

Lab6 (Advanced Queries)


Lab Submission Process:
Please use the Lab Submission Template (located in the root “Labs” folder) and
copy sql code for the following questions/queries in it.
Add your name, student Id, CRN in it, convert it to pdf document and upload
through D2L BrightSpace™ before the deadline.
Screen shots with a portion of expected result sets have been provided for your
convenience and for verification purposes.

INNER JOINS:
Q1: Create a query that returns vendor id, vendor names, invoice dates
and invoice total amounts. { schema: ap}

Using Four styles


a. JOIN in the WHERE clause (Intrinsic Style)
b. INNER JOIN or simply JOIN (Extrinsic Style)
c. USING keyword
d. NATURAL JOIN

Comp1168-Lab6(Rana) Page 1 of 5
Q2: Create a query that returns employees’ ids, full names and the
names of the departments they work in [This database has all
standalone tables and no inherent table relationships] { schema: ex}

Inner Join (employees who work in a department)

OUTER JOINS:
Q3: Create a query that would return the Full Name for all employees
and their department names including employees who do not work in
any department. {schema: ex}

Comp1168-Lab6(Rana) Page 2 of 5
(a) All employees who are in a department or who do not (Left Outer
Join)

(b) Create a query that would return the Full Name for all employees
and their department names including the departments with no
employees working in it {RIGHT Outer Join}

(c) Create a query that would return the Full Name for all employees
and their department names for those employees who do NOT work in
a department {WHERE d.department_name IS NULL}

Comp1168-Lab6(Rana) Page 3 of 5
(d) Create a query that would return Employee name and Department
Names even for all departments (with or without employees in them)
and all employees (with or without assigned to a department {FULL
Outer Join simulated with a UNION QUERY}

Query that retrieves data from two different schemas/databases


Q4: Create a query that returns all vendors (ap) and customers (om)
living in the same Zip Code (postal code) as shown below. This is a
query that two tables from different database.

Comp1168-Lab6(Rana) Page 4 of 5
FOUR TABLE JOIN with calculated column
Q5: Return customers’ and their order details as show below. {schema:
om}

Comp1168-Lab6(Rana) Page 5 of 5

You might also like