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

3 Using Single-Row Functions To Customize Output

The document provides instructions for an exercise on using single-row functions to customize output from database queries. It outlines 7 tasks for writing SQL queries to display employee data like name, salary, date of hire, and tenure using functions like GETDATE, ROUND, DATEDIFF. It also asks what the difference is between scalar and vector functions and which functions were used to display single row output.

Uploaded by

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

3 Using Single-Row Functions To Customize Output

The document provides instructions for an exercise on using single-row functions to customize output from database queries. It outlines 7 tasks for writing SQL queries to display employee data like name, salary, date of hire, and tenure using functions like GETDATE, ROUND, DATEDIFF. It also asks what the difference is between scalar and vector functions and which functions were used to display single row output.

Uploaded by

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

Page |1

INFORMATION TECHNOLOGY AND INFORMATION SYSTEM


DEPARTMENT

ADVANCED DATABASE MANAGEMENT SYSTEM

EXERCISE

3
USING SINGLE – ROW FUNCTIONS TO
CUSTOMIZE OUTPUT

NAME SECTION

DATE PERFORMED DATE FINISHED

GJPRosales
Page |2

I. OBJECTIVES

At the end of this exercise, students must be able to:


a. Write a query that displays the current date
b. Create queries that require the use of numeric, character, and date functions
c. Perform calculations of years and months of service of an employee.

II. BACKGROUND INFORMATION

FORMAT GETDATE ROUND

REPLICATE CONCAT LEN

DATEDIFF

III. EXPERIMENTAL PROCEDURE

PART 1:
Scenario
The HR department needs your assistance in creating some queries.

Task
Write the appropriate SQL statement for the following queries. The result of the
queries will be checked from your computer.

PROVIDE A SCREENSHOT OF THE SCRIPT AND THE OUTPUT PER STEP

1. The HR department needs a report to display the employee number, last name,
salary, and salary increased by 15.5% (expressed as a whole number) for each
employee. Label the column New Salary.

GJPRosales
Page |3

2. Modify your query in Task 1 to add a column that subtracts the old salary from
the new salary. Label the column Increase.

3. Write a query that displays the last name (with the first letter in uppercase and all
other letters in lowercase) and the length of the last name for all employees
whose name starts with the letters “J,” “A,” or “M.” Give each column an
appropriate label. Sort the results by the employees’ last names.

4. The HR department wants to find the duration of employment for each employee.
For each employee, display the last name and calculate the number of months
between today and the date on which the employees was hired. Label the
column s MONTHS_WORKED. Order your results by the number of months
employed. Round the number of months up to the closest whole number.

5. Create a query to display the last name and salary for all employees. Format the
salary to be 15 characters long, left-padded with the $ symbol. Label the column
as SALARY.

GJPRosales
Page |4

6. Create a query that displays the first eight characters of the employees’ last
names and indicates the amounts of their salaries with asterisks. Each asterisk
signifies a thousand dollars. Sort the data in descending order of salary. Label
the column as EMPLOYEES_AND_THEIR_SALARIES.

7. Create a query to display the last name and the number of weeks employed for
all employees in department 90. Label the number of weeks column as TENURE.
Truncate the number of weeks value to 0 decimal places. Show the records in
descending order of the employees’ tenure.

IV. QUESTION AND ANSWER

1. What is the difference between scalar function and vector function in database? What
function did we use to display a single row function?

GJPRosales
Page |5

V. REFERENCES

Hoffer, J.A., Prescott, M.B., McFadden, F.R. (2016). Modern Database Management
12th Edition, Prentice Hall.
Microsoft. (2012). Database Administration Fundamentals . USA: Wiley.

GJPRosales

You might also like