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

18l1382 Lab Repot 6 DB Updated

The document summarizes a lab report on learning advanced SQL features like set functions and subqueries. The lab tasks involved using SQL set functions like UNION, INTERSECT, and MINUS in exercises. Subqueries were also practiced in exercises to answer questions involving retrieving employee names based on project details. The conclusions state that advanced SQL commands were understood and can be used to retrieve data from databases. Applications of SQL advanced queries and subqueries were also mentioned.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

18l1382 Lab Repot 6 DB Updated

The document summarizes a lab report on learning advanced SQL features like set functions and subqueries. The lab tasks involved using SQL set functions like UNION, INTERSECT, and MINUS in exercises. Subqueries were also practiced in exercises to answer questions involving retrieving employee names based on project details. The conclusions state that advanced SQL commands were understood and can be used to retrieve data from databases. Applications of SQL advanced queries and subqueries were also mentioned.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

DB LAB

Name: Hamza sharif


Roll no: 18l1382
Lab report no.6
EXPERIMENT #6
Advanced SQL
Objective:
The objective of this lab is to learn and practice the advanced features of the SQL select
command just like set functions and subqueries in it.
Tools/Equipments:
laptop
SQL Server 2012 DBMS
Introduction:
SQL is a language designed for managing data in relational database management systems. SQL
stands for Structured Query Language. The following are SQL Advanced SQL set functions;
1. UNION
It is used to add and show the combined results of both queries.
2. INTERSECT
It is used to select only the common results from both queries.
3. MINUS
It is used to subtract the 2nd query from the 1st one.

Lab Task:
We were asked to understand and run the given SQL Advanced set functions in our SQL management
server. We performed and following is the output of SQL commands;

Exercise1: in the 1st exercise we practiced set functions such as;


Task 1a
1b
1c

1d

Exercise2: in 2nd exercise we practiced subqueries, following are the results;


2a

2b
2c

2d
2e

Exercise3: In the 3rd exercise we write SQL queries to answer the following questions:
1. Give the name(s) of employees who work either on project “ProductX” or on project
“ProductY”
2. Give the name(s) of employees who work both on project “ProductX” or on project
“ProductY”

3. Give the name(s) of employees who work on project “ProductY” but not on project
“ProductX”

4. Give the name(s) of employees who earn the minimum salary.


5. Give the names(s) of employees who work on as many projects as “Jennifer
Wallace”. Please exclude “Jennifer Wallace” from the list.

6. Give the names(s) of employees who work on a project which is not controlled by
their own department.
Conclusions:
We studied and understood the advanced SQL commands and to be able to use these SQL
advanced commands and functions to use and retrieve data from databases.
Issues:
No issues.

Applications:
SQL advanced queries are used for retrieving the data from a database.

Post lab:

A. Give the name(s) of guest who have booking both for Watergate or Latham hotel.
B. Give the name(s) of guest who have booking either for Watergate and Latham hotel.

C. Give the name(s) of guest who have booking for Latham but not for Watergate hotel.
D. Display the name of the guest who has stayed in maximum number of hotels

E. Display the name of the hotel with as many rooms as Latham hotel
F. Display the name of the hotel with the cheapest room

Issue:
There was no issue during the lab work.
Conclusion:
A subquery is a select query that is enclosed inside another query. The inner select query is usually used
to determine the results of the outer select query. Subqueries are a major part of Advanced SQL.
Application:
SQL is compatible with most databases like Microsoft Access, MySQL, and others. Furthermore, since
most relational database management systems support SQL functions, one can use them to develop
application extensions that cater to procedural programming

You might also like