Objectives
After completing this lesson, you should be able to do the following:
• Describe various types of functions available in SQL
• Use character, number, and date functions in SELECT statements
• Describe the use of conversion functions.
• Describe various types of functions available in SQL
• Use character, number, and date functions in SELECT statements
• Describe the use of conversion functions.
SQL Functions
Two Types of SQL Functions
Single-Row Functions
Single row functions:
• Manipulate data items
• Accept arguments and return one value
• Act on each row returned
• Return one result per row
• May modify the data type
• Can be nested
• Accept arguments which can be a column or an expression.
Two Types of SQL Functions
Single-Row Functions
• Manipulate data items
• Accept arguments and return one value
• Act on each row returned
• Return one result per row
• May modify the data type
• Can be nested
• Accept arguments which can be a column or an expression.
Character Functions
Case Manipulation Functions
These functions convert case for character strings.
Using Case Manipulation Functions
Case Manipulation Functions
These functions convert case for character strings.
Using Case Manipulation Functions
Display the employee number, name, and department number for employee Higgins:
Character-Manipulation Functions
These functions manipulate character strings:
Using the Character-Manipulation Functions
Number Functions
• ROUND: Rounds value to specified decimal
• TRUNC: Truncates value to specified decimal
• MOD: Returns remainder of division
Using the ROUND Function
Character-Manipulation Functions
These functions manipulate character strings:
Using the Character-Manipulation Functions
Number Functions
• ROUND: Rounds value to specified decimal
• TRUNC: Truncates value to specified decimal
• MOD: Returns remainder of division
Using the ROUND Function
DUAL is a dummy table you can use to view results from functions and calculations.
Using the TRUNC Function
Using the MOD Function
Using the MOD Function
Calculate the remainder of a salary after it is divided by 5000 for all employees whose job title is sales representative.
Working with Dates
Working with Dates
• Oracle database stores dates in an internal numeric format: century, year, month, day, hours,
minutes, seconds.
• The default date display format is DD-MON-RR.
– Allows you to store 21st century dates in the 20th century by specifying only the last two digits of the year.
– Allowa you to store 20th century dates in the 21st century in the same way.
minutes, seconds.
• The default date display format is DD-MON-RR.
– Allows you to store 21st century dates in the 20th century by specifying only the last two digits of the year.
– Allowa you to store 20th century dates in the 21st century in the same way.
No comments:
Post a Comment