Académique Documents
Professionnel Documents
Culture Documents
String Functions
A string is a bunch of things such as
houses, places numbers, or characters
in a sentences
It includes any mixture of letters,
numbers,
spaces
and symbols(special
Function
Use
Name
characters/punctuations
etc)
| |
ASCII
CHR
INITCAP
String Functions
Function Name Use
INSTR
LENGTH
LOWER
LTRIM
RTEIM
SOUNDEX
SUBSTR
TRIM
UPPER
Reverse
String Functions
Table LOCATION is created :Column
Name
Data Type
Nullabl Defaul
e
t
CITY
VARCHAR
Yes
COUNTRY
VARCHAR
Yes
Yes
Yes
TEMPERAT
NUMBER
URE
POPULATIO
NUMBER
N
Primary
Key
String Functions
Table location with data..
CITY
athens
COUNTRY
greece
TEMPERATU POPULATIO
RE
N
56
100000
chicago
united states
50
200000
lima
peru
75
300000
madras
india
60
400000
london
england
30
500000
moscow
russia
20
600000
paris
france
35
700000
bejing
china
55
800000
rome
italy
65
900000
tokyo
japan
45
900000
colombo
sri lanka
80
1100000
String Functions
1) concatenation: Select city ||country from location;
CITY||COUNTRY
athens greece
chicago united states
lima peru
madras india
london england
moscow russia
paris france
bejing china
rome italy
tokyo japan
colombo sri lanka
Select city || , ||
country from
location
String Functions
TRIM,RTRIM,LTRIM: Select RTRIM(city, ) from location;
They trims unwanted characters from the
left, right or from both ends
Select RTRIM(city, ) from location;
Set of characters being
trimmed
String Functions
LOWER: Select lower(YTC) from dual;
Select lower(city) from location;
String Functions
Length: Tells no. of characters in a string
Select population, length(population) from
location;
String Functions
INSTR: It doesnt clip anything off.
Allows searching through a string for a set
of characters
Syntax:- INSTR(string,start, occurance)..
Select instr(YSPMYTC,set,1,2) from
dual;
Set part of function is case sensitive..
String Functions
ASCII and CHR: select chr(70) || chr(83)||chr(85) ||
chr(71)as chr_Values from dual;
CHR_VALUE
S
FSUG
String Functions
SOUNDEX: It has ability to find words that sounds like
other words, virtually regardless of how
either is spelled.
This is specially useful, when we are not
certain about a word or name is really
spelled..
Syntax:- SOUNDEX(string)
SOUNDEX compares he sound of the entry
in the selected column with the sound of
the word in a single quotation marks, & it
looks for a close match..
SQL GROUP
Functions
SQL DISTINCT():
This function is used to select the distinct rows.
For Example: If you want to select all distinct
department names from employee table, the query
would be:
SELECT DISTINCT dept FROM employee;
SQL MIN():
This function is used to get the minimum
value from a column.
To get the minimum salary drawn by an
employee, the query would be:
SELECT MIN (salary) FROM employee;
SQL SUM():
This function is used to get the sum of a
numeric column
To get the total salary given out to the
employees,
SELECT SUM (salary) FROM employee;
Date Function
1) SYSDATE: Select sysdate from dual;
Date Function
Which holiday are not celebrated on actual date of
their anniversary, this can be easily answered by
subtracting celebration date from actualdate.
If the answer is not zero , there is difference
between the two dates.
Date Function
Date Function
Date Function
Date Function
Date Function