Dbmslab 3

You might also like

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

Bahria University,

Karachi Campus

LAB EXPERIMENT NO.


03

LIST OF TASKS
TASK NO OBJECTIVE
01 Retrieve the title and publication date of books. If the publication date is NULL, display "Not
available" instead.
02 Combine the author's first name and last name into a single column and display it in uppercase.
03 Find the difference in days between the current date and the hire date of employees in the
"employee" table.
04 Determine the years of experience of each employee based on their hiring date. (Tabel: Employee,
Database: Pubs)
05 Replace the substring "St" with "Street" in the authors’ addresses.
06 Show the order date and the order month for all orders in the "orders" table.
07 List the products along with their units in stock. If units in stock are NULL, display "Out of stock.
08 Display the absolute value of the difference between the units in stock and the units on order for
each product.
09 Combine the first three letters of the customer's city and the first two letters of the country for
each customer.
10 Use getdate() function to get system date then use datepart() function to extract month, year and
date from it.
11 Use getdate() function to get system date then use day(), month() and year() functions to extract
month, year and date from it

Submitted On:
Date: 11/03/24
[Lab # [DATABASE MANAGEMENT SYSTEMS LAB]
03] [SQL Functions]

Task No. 01:


Retrieve the title and publication date of books. If the publication date is NULL, display "Not available"
instead.

Solution:

Output:

(No “Not available” output since there is no null value in pubdate column)

Task No. 02:


Combine the author's first name and last name into a single column and display it in uppercase.

Solution:

Zuhaib Shamsheer 02-131222-


104
[Lab # [DATABASE MANAGEMENT SYSTEMS LAB]
03] [SQL Functions]

Output:

Task No. 03:


Find the difference in days between the current date and the hire date of employees in the "employee" table.

Solution:

Output:

Zuhaib Shamsheer 02-131222-


104
[Lab # [DATABASE MANAGEMENT SYSTEMS LAB]
03] [SQL Functions]

Task No. 04:


Determine the years of experience of each employee based on their hiring date. (Tabel: Employee, Database:
Pubs)

Solution:

Output:

Task No. 05:


Replace the substring "St" with "Street" in the authors’ addresses.

Solution:

Zuhaib Shamsheer 02-131222-


104
[Lab # [DATABASE MANAGEMENT SYSTEMS LAB]
03] [SQL Functions]

Output:

Task No. 06:


Show the order date and the order month for all orders in the "orders" table.

Solution:

Output:

Zuhaib Shamsheer 02-131222-


104
[Lab # [DATABASE MANAGEMENT SYSTEMS LAB]
03] [SQL Functions]

Task No. 07:


List the products along with their units in stock. If units in stock are NULL, display "Out of stock.

Solution:

Output:

(No “Out of Stock” output since there is no “NULL” value in UnitInStock Column)

Task No. 08:


Display the absolute value of the difference between the units in stock and the units on order for each product.

Solution:

Zuhaib Shamsheer 02-131222-


104
[Lab # [DATABASE MANAGEMENT SYSTEMS LAB]
03] [SQL Functions]

Output:

Task No. 09:


Combine the first three letters of the customer's city and the first two letters of the country for each customer.

Solution:

Output:

Zuhaib Shamsheer 02-131222-


104
[Lab # [DATABASE MANAGEMENT SYSTEMS LAB]
03] [SQL Functions]

Task No. 10:


Use getdate() function to get system date then use datepart() function to extract month, year and date from it.

Solution:

Output:

Task No. 11:


Use getdate() function to get system date then use day(), month() and year() functions to extract month, year
and date from it

Solution:

Output:

Zuhaib Shamsheer 02-131222-


104

You might also like