Unit 4 - Usage of Single-Row Functions To Customize Output
Unit 4 - Usage of Single-Row Functions To Customize Output
Agenda
Syntax:
function_name [(arg1, arg2,...)]
Single-Row Functions
This lesson covers the following single-row functions:
• Date functions: Operate on values of the DATE data type (All date
functions return a value of the DATE data type except the
MONTHS_BETWEEN function, which returns a number)
Character Functions
Character functions can be divided into the following:
• Case-conversion functions
• Character-manipulation functions
or
F3(F2(F1(col,arg1),arg2),arg3)
SELECT last_name,
UPPER(CONCAT(SUBSTR(LAST_NAME,1,8),'_RO')) Info
FROM employees
WHERE department_id = 60;
Numeric Functions
Numeric functions accept numeric input and return numeric values.
This section describes some of the numeric functions
SELECT ROUND(45.923,2),ROUND(45.923,0),ROUND(45.923,-1)
• Date
• Time
SELECT sysdate();
Arithmetic with Dates
• Add to or subtract a number from a date for a resultant date value
• Subtract two dates to find the number of days between those dates
(DATEDIFF, TIMESTAMPDIFF )
• Add hours to a date
SELECT last_name, ??? AS WEEKS
FROM employees
WHERE department_id = 90;
• Display the employee number, hire date, and starting month for all
employees who started in 2004.
SELECT employee_id, hire_date,DATE_FORMAT(hire_date,
'%Y-%m-01')
FROM employees
WHERE hire_date LIKE '%04’;
Quiz
• Creating queries that require the use of numeric, character, and date
functions