Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 19

Bahria University,

Karachi Campus

COURSE: CEN-221
Database Management System Lab
TERM: FALL 2022, CLASS: BSE- 4(A)

Submitted By:

_______________________________________________
(Name) Zuhaib Shamsher (Reg. No.) 02-131222-104

Submitted To:

Engr. Bushra Fazal/Engr. Noor us Sabah

Signed Remarks: Score:_____


INDEX
SNO DATE LAB LAB OBJECTIVE SIGN
NO

01 17/02/2 01 Querying Database Tables Using


4 Select
SNO DATE LAB LAB OBJECTIVE SIGN
NO
Bahria University,
Karachi Campus

LAB EXPERIMENT NO.


_1_

LIST OF TASKS
TASK NO OBJECTIVE
1 a) Get Order id, Product id, Unit price from Order Details.
b) Display all cities that employees belong to but don’t allow repetition.
c) Find complete name of all employees.
d) Display data of all employees those working as Sales Representative.
e) Display complete name of employees those livesin London.
f) Display product name whose unit price are greater than 90$.
g) List the name of all employees whose first name starts with the letter ‘A’.
In Customer table, display all cities that ends with the letter ‘a’.
h) Display names of all employees whose name contain ‘an’.
Display all the orders where unit price lies in the range of 10$ to 40$.
i) Display the company name where Region is NULL in Customer Table.
j) Write a query to list employees who live in London, Seattle or Redmond
k) Write a query to list employees whose address contains 3 numbers in its start.
Write a query to list employees whose address does not contain Rd.
l) Write a query to listthose employees whose TitleofCourtesy does not starts
with M.
m) List order whose ShipRegion is not Null.
n) List all products where UnitPrice is between 10 and 15 and QuantityPerUnit
contains “bottles”.
o) List all products where UnitPrice is not in 10,12,15,17 or 19.

Submitted On:
Date: _17/02/2024__
[Lab no. 01] [Database Management System Lab]
[Querying Database Tables Using Select]

Task No. 01:


“a) Get Order id, Product id, Unit price from Order Details. “

Solution:

select OrderID, ProductID, UnitPrice from [Order Details];

Output:

Zuhaib Shamsheer 02-131222-104


[Lab no. 01] [Database Management System Lab]
[Querying Database Tables Using Select]

Task No. 02:


“d) Display all cities that employees belong to but don’t allow repetition “

Solution:

select distinct City from employees

Output:

Zuhaib Shamsheer 02-131222-104


[Lab no. 00] [COMPUTER ARCHITECTURE AND LOGIC DESIGN]
[Introduction to VVM]

Task No. 03:


“e) Find complete name of all employees. “

Solution:
select FirstName +' '+ LastName as fullname from Employees

Output:

Zuhaib Shamsheer 02-131222-104


[Lab no. 00] [COMPUTER ARCHITECTURE AND LOGIC DESIGN]
[Introduction to VVM]

Task No. 04:


“f) Display data of all employees those working as Sales Representative “

Solution:
select * from Employees where title='sales representative'

Output:

Zuhaib Shamsheer 02-131222-104


[Lab no. 00] [COMPUTER ARCHITECTURE AND LOGIC DESIGN]
[Introduction to VVM]
Task No. 05:
“g) Display complete name of employees those livesin London. “

Solution:

select Firstname +' '+ Lastname as fullname from Employees where city='london'

Output:

Zuhaib Shamsheer 02-131222-104


[Lab no. 00] [COMPUTER ARCHITECTURE AND LOGIC DESIGN]
[Introduction to VVM]
Task No. 06:
“h) Display product name whose unit price are greater than 90$. “

Solution:
select productname from Products where UnitPrice>90

Output:

Zuhaib Shamsheer 02-131222-104


[Lab no. 00] [COMPUTER ARCHITECTURE AND LOGIC DESIGN]
[Introduction to VVM]
Task No. 07:
“i) List the name of all employees whose first name starts with the letter ‘A’. “

Solution:
select firstname +' '+ lastname as fullname from Employees where FirstName like 'A%'

Output:

Zuhaib Shamsheer 02-131222-104


[Lab no. 00] [COMPUTER ARCHITECTURE AND LOGIC DESIGN]
[Introduction to VVM]

Task No. 08:


“k) Display names of all employees whose name contain ‘an’. “

Solution:
select firstname +' '+ lastname as fullname from Employees where City like '%an%'

Output:

Zuhaib Shamsheer 02-131222-104


[Lab no. 00] [COMPUTER ARCHITECTURE AND LOGIC DESIGN]
[Introduction to VVM]

Task No. 9:
“m) Display the company name where Region is NULL in Customer Table “

Solution:
select CompanyName,Region from Customers where Region is NULL

Output:

Zuhaib Shamsheer 02-131222-104


[Lab no. 00] [COMPUTER ARCHITECTURE AND LOGIC DESIGN]
[Introduction to VVM]

Task No. 10:


“n) Write a query to list employees who live in London, Seattle or Redmond “

Solution:
select FirstName+''+LastName as FullName from Employees where City in ('London','Seattle','Redmond')

Output:

Zuhaib Shamsheer 02-131222-104


[Lab no. 00] [COMPUTER ARCHITECTURE AND LOGIC DESIGN]
[Introduction to VVM]

Task No. 11:


“o) Write a query to list employees whose address contains 3 numbers in its start.. “

Solution:

select FirstName+''+LastName as FullName from Employees where Address like '___%'

Output:

Zuhaib Shamsheer 02-131222-104


[Lab no. 00] [COMPUTER ARCHITECTURE AND LOGIC DESIGN]
[Introduction to VVM]

Task No. 12:


“q) Write a query to listthose employees whose TitleofCourtesy does not starts with M “

Solution:
select FirstName+''+LastName as FullName from Employees where TitleOfCourtesy not like '[^M]%'

Output:

Zuhaib Shamsheer 02-131222-104


[Lab no. 00] [COMPUTER ARCHITECTURE AND LOGIC DESIGN]
[Introduction to VVM]

Task No. 13:


“r) List order whose ShipRegion is not Null. “

Solution:
select * from Orders where ShipRegion is not null

Output:

Zuhaib Shamsheer 02-131222-104


[Lab no. 00] [COMPUTER ARCHITECTURE AND LOGIC DESIGN]
[Introduction to VVM]
Task No. 14:
“s) List all products where UnitPrice is between 10 and 15 and QuantityPerUnit contains
“bottles”.. “

Solution:
select * from Products where unitprice between '10' and '15' and QuantityPerUnit like '%bottles'

Output:

Zuhaib Shamsheer 02-131222-104


[Lab no. 00] [COMPUTER ARCHITECTURE AND LOGIC DESIGN]
[Introduction to VVM]
Task No. 15:
“t) List all products where UnitPrice is not in 10,12,15,17 or 19. “

Solution:
select * from Products where unitprice not in ('10','12','15','17','19')

Output:

Zuhaib Shamsheer 02-131222-104

You might also like