Lecture05 SingleRowFunctions Part1
Lecture05 SingleRowFunctions Part1
Introduction to Database
Lecture 05:
Single-Row Functions (Part 1)
Learning Objectives
2
To know about:
SQL Functions
Types of SQL Functions
Single-Row Functions
Character Functions
Number Functions
Date Functions
SQL Functions
3
Input Output
Function
arg 1 Function
performs action
arg 2
Result
value
arg n
Two Types of SQL Functions
4
Functions
Single-row Multiple-row
functions functions
Single-Row Functions
5
• Manipulate data items
• Accept arguments and return one value
• Act on each row returned
• Return one result per row
• May modify the datatype
• Can be nested
Character
General Number
Single-row
functions
Conversion Date
Character Functions
7
Character
functions
ENAME WEEKS
---------- ---------
KING 830.93709
CLARK 853.93709
MILLER 821.36566
Date Functions
19
Function Description
• MONTHS_BETWEEN ('01-SEP-95','11-JAN-94')
19.6774194
• LAST_DAY('01-SEP-95') '30-SEP-95'
Using Date Functions
21
Round(to_date(’25-jul-05’),’month’) 01-Aug-05
Round(to_date(’25-jul-05’),’Year’) 01-Jan-06
Trunc(to_date(’25-jul-05’),’month’) 01-Jul-05
Trunc(to_date(’25-jul-05’),’year’) 01-Jan-05
22
THANK YOU