02.Oracle Single Row Functions.sql
02.Oracle Single Row Functions.sql
Chapter Content :
Chapter02:Oracle Single Row Functions
What is Function ?
Chapter02:Oracle Single Row Functions
Character Functions
Lower
Upper
Initcap
Substr
instr
lpad
rpad
length
replace
concat
trim
Chapter02:Oracle Single Row Functions
Character Functions:
Lower – Upper – Initcap
Chapter02:Oracle Single Row Functions
Character Functions:
Length ( String )
Chapter02:Oracle Single Row Functions
Character Functions:
Replace ( String 1 , String2 , String3 )
Character Functions:
Concat ( String 1 , String 2 )
Chapter02:Oracle Single Row Functions
Character Functions:
Concat ( String 1 , String 2 )
Chapter02:Oracle Single Row Functions
Character Functions:
Trim ( String from String)
Trim ( ‘A’ From ‘AAABMOALHKGGAA’ ) - BMOALHKGG
Chapter02:Oracle Single Row Functions
Character Functions:
Lpad ( String , Number , String)
Rpad ( String , Number , String )
Chapter02:Oracle Single Row Functions
Character Functions:
Substr( String , Number , Number)
Substr( String , Start Point, Length of characters )
Character Functions:
Substr( String , Number , Number)
Substr( String , Start Point, Length of characters )
Character Functions:
Substr( String , Number , Number)
Substr( String , Start Point, Length of characters )
Character Functions:
instr( String , String, Number , Number)
Character Functions:
instr( String , String, Number , Number)
Number Functions:
round
trunc
mod
Chapter02:Oracle Single Row Functions
Number Functions:
Round ( Number1 , Number 2):
Number Functions:
Round ( Number1 , Number 2):
Number Functions:
Trunc ( Number1 , Number 2):
Number Functions:
Number Functions:
Practices01 :
------------------------------------------------------------------------
• Write a Query Based on emp table to display the following output: select *
from emp
where substr ( ename , 1 , 1 ) in ( 'A' , 'S' , 'T') ;
Empno ename sal ? -----------------------------------------------------------------------
---------------------------------------------------- select *
7788 SCOTT 3000 *** from emp
where length ( ename) > 4
7789 Turner 2870 ** ------------------------------------------------------------------------
7790 Alen 1200 * select *
7791 Ward 5000 ***** from emp
where instr ( ename , 'L' , 1, 2 ) > 0
7792 AAAA 800 null ------------------------------------------------------------------------
-
select empno , ename , sal , trunc ( sal / 1000 ) ,
• Write a Query to display employee names in Capital letter lpad ( '*' , trunc ( sal / 1000 ) , '*')
• from emp
Write a Query to display employees with Double L in their names
------------------------------------------------------------------------
• Write a query to display employees with their names start with ( ‘S’ , ‘T’ , ‘A’ ) -
• Write a query to display employees with name length greater than 4
Chapter02:Oracle Single Row Functions
to_char
to_number
to_date
Chapter02:Oracle Single Row Functions
Date Format
------------
day : d dd day dy
month : mm month MON
year : yy yyyy year
number format :
-------------
$ L . , 9 0
Chapter02:Oracle Single Row Functions
Oracle Functions
Practices
• Write a Query to Display Employee Hire date , Employee Actual hire date if the actual hiredate increase by 6 months
Than hire date
• Write query to display for each employee the number of worked months , name the column Months_worked
• Write a query to diaply for each employee the number of days worked , name the column days_worked
• Write a query to display the hiredate in this format Example ( ‘Wednesday 22 January 1990 )
• Write a query to diaply the salary of the employee in this format example ( 003000.00)
• Write a query to display the salary of the employee , the comm and the sum of salary + comm ( avoid nulls )