Professional Documents
Culture Documents
Chapter 5
Chapter 5
Chapter 5
Single-Row Function(1)
Objectives
Understand
What is Function?
A function
Sorting function
A
F
G
R
T
Single-row
functions
Multiple-row
functions
Single-Row Functions
Manipulate
data items
Accept arguments and return one value
Act on each row returned
Return one result per row
Can modify the data type
Can be nested
Single-Row Functions
Single-row
functions
Number
Text
This chapter
Date
Conversion
Chapter 6
function_name Is
function
column Is any named database column
expression Is any character
string or
calculated expression
arg1, arg2 Is any argument to be used
by the function
Number Functions
Function name
Description
Remainder after
division
Note: There are lots of other Number functions but the one highlights in the course
is more useful
Round to 1
5
5.3
Round to 2
5.26
Text Functions
Text
functions
Case conversion
functions
String manipulation
functions
UCase
LCase
Mid
Trim
StrConv
Len
Instr
Left / Right
Description
UCase (column/expression)
or
StrConv(column/expression, 1)
LCase (column/expression)
or
StrConv(column/expression, 2)
StrConv(column/expression, 3)
LowerCase
smith
Using StrConv
SELECT StrConv('my name',1) as [UpperCase],
StrConv('my name',2) as [LowerCase],
StrConv('my name',3) as [Initial]
FROM test;
Output:
UpperCase
MY NAME
LowerCase
my name
Initial
My Name
Description
Left(stringexpression, n)
Or
Right(stringexpression, n)
Returns a portion of a
string starting either left or
right.
Trim(stringexpression)
Len(stringexpression)
MID Function
Mid (stringexpression, start, length)
Stringexpression
The
Start
Tells Access
Length
The
Rest of String
Computer
Computer Studies
Gaming a
Computin
Computing
Info-Com
Info-Comm Technology
Informat
Information Technology
Network
INSTR Function
Instr (start, stringexpression, search_string)
Start
Specify
Stringexpression
The
Search_string
The
Position of C
12
35
Diploma In Computing
12
17
26
24
Right (stringexpression, n)
Stringexpression
The
n
The
MentorName
Right
Goile
Goi
ile
Rimes
Rim
mes
Christopher
Chr
her
Schubert
Sch
ert
Norman
Nor
man
Carroll
Car
oll
TRIM Function
Trim (stringexpression)
Stringexpression
The
Hello
Output:
Greetings
Hello
) As [Greetings] .
LEN Function
Len (stringexpression)
Stringexpression
The
Length
Goile
Rimes
Christopher
11
Schubert
Norman
Carroll
Name
Joseph , B
Laura , K
Choy , L
Derrick , L
Arthur , L
Kathleen , M
Summary
Must