SlideShare una empresa de Scribd logo
1 de 29
Chapter 5
Single-Row Function(1)
Objectives
 Understand the usage of functions in
SELECT statements
 Using Number and Text functions
What is Function?
 A function is a type of procedure or routine
that performs a specific task.
 A function can receive argument and
always returns a value.
Sorting function
F
T
G
A
R
A
F
G
R
T
Two Types of SQL Functions
Functions
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 Date Conversion
This chapter Chapter 6
Calling a Function in SQL
function_name Is the name of the
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
function_name (column|expression, [arg1, arg2,...])
Number Functions
Function name Description
Round (column/expression,
precision)
Round to a specified
precision
Mod
Example: ( x mod y)
Remainder after
division
Note: There are lots of other Number functions but the one highlights in the course
is more useful
Using ROUND Function
(a) Round Function
SELECT Round(5.255,0) as [Round to 0],
Round(5.255,1) as [Round to 1],
Round(5.255,2) as [Round to 2]
FROM test;
Output:
Round to 0 Round to 1 Round to 2
5 5.3 5.26
Using Mod Function
It will return the remainder of a division.
SELECT 10 mod 3 As [Mod]
FROM test;
Output:
Mod
1
Text Functions
Text
functions
UCase
LCase
StrConv
Case conversion
functions
String manipulation
functions
Mid
Trim
Len
Instr
Left / Right
Case Conversion Functions
Functions name Description
UCase (column/expression)
or
StrConv(column/expression, 1)
Puts all the letters in uppercase
LCase (column/expression)
or
StrConv(column/expression, 2)
Puts all the letters in lower case
StrConv(column/expression, 3) Capitalizes the first letter of each
word and puts all the other letters
in lowercase.
Using UCase & LCase
SELECT Ucase('smith') AS UpperCase,
Lcase('SMITH') As LowerCase
FROM test;
Output:
UpperCase LowerCase
SMITH 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 LowerCase Initial
MY NAME my name My Name
Example of Case conversion
SELECT Ucase (CourseDesp) as [Course Name]
FROM Course;
Output:
Course Name
DIPLOMA IN COMPUTER STUDIES
DIPLOMA IN GAMING AND ANIMATION TECHNIQUES
DIPLOMA IN COMPUTING
DIPLOMA IN INFO-COMM TECHNOLOGY
DIPLOMA IN INFORMATION TECHNOLOGY
DIPLOMA IN NETWORK AND CYBERSECURITY
String Manipulation Functions
 Perform operations of string such as
creating a substring
 Extract a portion of the string to create a
new character string output
 These functions are useful when you want
to lookup certain data /values from a
particular string.
String Manipulation Functions
Functions Name Description
Mid (stringexpression, start, length) Returns part of a string.
Instr(start, stringexpression, search_string) Finds the occurrence of
some search-string pattern
Left(stringexpression, n)
Or
Right(stringexpression, n)
Returns a portion of a
string starting either left or
right.
Trim(stringexpression) Removes blanks spaces
from both sides of a string
Len(stringexpression) Returns the length of a
string
MID Function
Mid (stringexpression, start, length)
 Stringexpression
 The field or the value that will be use for the function
to manipulate.
 Start
 Tells Access where in the stringexpression to start
retrieving from
 Length
 The number of characters to extract. If the length is
absent, then function will returns the rest of the string
from where you start.
Example on MID function
Output:
Middle of String Rest of String
Computer Computer Studies
Gaming a Gaming and Animation Techniques
Computin Computing
Info-Com Info-Comm Technology
Informat Information Technology
Network Network and CyberSecurity
SELECT Mid(CourseDesp,12,8) As [Middle of String],
Mid(CourseDesp,12) As [Rest of String]
FROM course;
INSTR Function
Instr (start, stringexpression, search_string)
 Start
 Specify the position from which Access will start
reading the stringexpression.
 Stringexpression
 The field or the value that will be use for searching.
 Search_string
 The value or the pattern that you looking for in the
stringexpression
Example on INSTR Function
Output:
CourseDesp Position of C
Diploma In Computer Studies 12
Diploma in Gaming and Animation
Techniques
35
Diploma In Computing 12
Diploma In Info-Comm Technology 17
Diploma In Information Technology 26
Diploma in Network and CyberSecurity 24
SELECT CourseDesp, Instr(1,CourseDesp,'C')
As [Position of C]
FROM course;
LEFT / RIGHT Function
Left (stringexpression, n)
Or
Right (stringexpression, n)
 Stringexpression
 The field or the value that will be use for
manipulate.
 n
 The number of characters that will be
returned from the stringexpression.
Example on LEFT/RIGHT function
SELECT MentorName, Left(MentorName,3) As
[Left], Right(MentorName,3) As [Right]
FROM Mentor;
Output
MentorName
Left 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 field or the value that spaces need to be
removed
Example on TRIM function
SELECT TRIM(‘ Hello ’) As [Greetings] ….
Output:
Greetings
Hello
LEN Function
Len (stringexpression)
 Stringexpression
 The field or the value that the length to be
calculate.
Example on LEN Function
SELECT MentorName, Len(MentorName) As [Length]
FROM Mentor;
Output:
MentorName
Length
Goile 5
Rimes 5
Christopher 11
Schubert 8
Norman 6
Carroll 7
Using String Functions
SELECT Mid(FirstName,1,Instr(1,FirstName,' ')) & ', ' &
left(lastname,1) AS [Name]
FROM Student;
Output:
Name
Joseph , B
Laura , K
Choy , L
Derrick , L
Arthur , L
Kathleen , M
………
Summary
 Must know the features of Single-Row
functions.
 Usage of both Text and Number
functions.

Más contenido relacionado

Similar a Chapter-5.ppt

Intro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technologyIntro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technologyworldchannel
 
Diploma ii cfpc u-4 function, storage class and array and strings
Diploma ii  cfpc u-4 function, storage class and array and stringsDiploma ii  cfpc u-4 function, storage class and array and strings
Diploma ii cfpc u-4 function, storage class and array and stringsRai University
 
Mcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and stringsMcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and stringsRai University
 
SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)Logan Palanisamy
 
Bsc cs i pic u-4 function, storage class and array and strings
Bsc cs i pic u-4 function, storage class and array and stringsBsc cs i pic u-4 function, storage class and array and strings
Bsc cs i pic u-4 function, storage class and array and stringsRai University
 
function, storage class and array and strings
 function, storage class and array and strings function, storage class and array and strings
function, storage class and array and stringsRai University
 
Btech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and stringsBtech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and stringsRai University
 
Functions torage class and array and strings-
Functions torage class and array and strings-Functions torage class and array and strings-
Functions torage class and array and strings-aneebkmct
 
Database Query Using SQL_ip.docx
Database Query Using SQL_ip.docxDatabase Query Using SQL_ip.docx
Database Query Using SQL_ip.docxVandanaGoyal21
 
Visula C# Programming Lecture 6
Visula C# Programming Lecture 6Visula C# Programming Lecture 6
Visula C# Programming Lecture 6Abou Bakr Ashraf
 
Matlab Functions
Matlab FunctionsMatlab Functions
Matlab FunctionsUmer Azeem
 

Similar a Chapter-5.ppt (20)

Intro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technologyIntro to C# - part 2.pptx emerging technology
Intro to C# - part 2.pptx emerging technology
 
Diploma ii cfpc u-4 function, storage class and array and strings
Diploma ii  cfpc u-4 function, storage class and array and stringsDiploma ii  cfpc u-4 function, storage class and array and strings
Diploma ii cfpc u-4 function, storage class and array and strings
 
Mcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and stringsMcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and strings
 
SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)
 
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
Introduction to Oracle Functions--(SQL)--Abhishek SharmaIntroduction to Oracle Functions--(SQL)--Abhishek Sharma
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
 
Bsc cs i pic u-4 function, storage class and array and strings
Bsc cs i pic u-4 function, storage class and array and stringsBsc cs i pic u-4 function, storage class and array and strings
Bsc cs i pic u-4 function, storage class and array and strings
 
function, storage class and array and strings
 function, storage class and array and strings function, storage class and array and strings
function, storage class and array and strings
 
Btech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and stringsBtech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and strings
 
Functions torage class and array and strings-
Functions torage class and array and strings-Functions torage class and array and strings-
Functions torage class and array and strings-
 
Single row functions
Single row functionsSingle row functions
Single row functions
 
Database Query Using SQL_ip.docx
Database Query Using SQL_ip.docxDatabase Query Using SQL_ip.docx
Database Query Using SQL_ip.docx
 
SQL.ppt
SQL.pptSQL.ppt
SQL.ppt
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
Functions
FunctionsFunctions
Functions
 
Visula C# Programming Lecture 6
Visula C# Programming Lecture 6Visula C# Programming Lecture 6
Visula C# Programming Lecture 6
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
interenship.pptx
interenship.pptxinterenship.pptx
interenship.pptx
 
Module03
Module03Module03
Module03
 
Sql
SqlSql
Sql
 
Matlab Functions
Matlab FunctionsMatlab Functions
Matlab Functions
 

Último

"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 

Último (20)

"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 

Chapter-5.ppt

  • 2. Objectives  Understand the usage of functions in SELECT statements  Using Number and Text functions
  • 3. What is Function?  A function is a type of procedure or routine that performs a specific task.  A function can receive argument and always returns a value. Sorting function F T G A R A F G R T
  • 4. Two Types of SQL Functions Functions Single-row functions Multiple-row functions
  • 5. 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
  • 6. Single-Row Functions Single-row functions Number Text Date Conversion This chapter Chapter 6
  • 7. Calling a Function in SQL function_name Is the name of the 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 function_name (column|expression, [arg1, arg2,...])
  • 8. Number Functions Function name Description Round (column/expression, precision) Round to a specified precision Mod Example: ( x mod y) Remainder after division Note: There are lots of other Number functions but the one highlights in the course is more useful
  • 9. Using ROUND Function (a) Round Function SELECT Round(5.255,0) as [Round to 0], Round(5.255,1) as [Round to 1], Round(5.255,2) as [Round to 2] FROM test; Output: Round to 0 Round to 1 Round to 2 5 5.3 5.26
  • 10. Using Mod Function It will return the remainder of a division. SELECT 10 mod 3 As [Mod] FROM test; Output: Mod 1
  • 11. Text Functions Text functions UCase LCase StrConv Case conversion functions String manipulation functions Mid Trim Len Instr Left / Right
  • 12. Case Conversion Functions Functions name Description UCase (column/expression) or StrConv(column/expression, 1) Puts all the letters in uppercase LCase (column/expression) or StrConv(column/expression, 2) Puts all the letters in lower case StrConv(column/expression, 3) Capitalizes the first letter of each word and puts all the other letters in lowercase.
  • 13. Using UCase & LCase SELECT Ucase('smith') AS UpperCase, Lcase('SMITH') As LowerCase FROM test; Output: UpperCase LowerCase SMITH smith
  • 14. 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 LowerCase Initial MY NAME my name My Name
  • 15. Example of Case conversion SELECT Ucase (CourseDesp) as [Course Name] FROM Course; Output: Course Name DIPLOMA IN COMPUTER STUDIES DIPLOMA IN GAMING AND ANIMATION TECHNIQUES DIPLOMA IN COMPUTING DIPLOMA IN INFO-COMM TECHNOLOGY DIPLOMA IN INFORMATION TECHNOLOGY DIPLOMA IN NETWORK AND CYBERSECURITY
  • 16. String Manipulation Functions  Perform operations of string such as creating a substring  Extract a portion of the string to create a new character string output  These functions are useful when you want to lookup certain data /values from a particular string.
  • 17. String Manipulation Functions Functions Name Description Mid (stringexpression, start, length) Returns part of a string. Instr(start, stringexpression, search_string) Finds the occurrence of some search-string pattern Left(stringexpression, n) Or Right(stringexpression, n) Returns a portion of a string starting either left or right. Trim(stringexpression) Removes blanks spaces from both sides of a string Len(stringexpression) Returns the length of a string
  • 18. MID Function Mid (stringexpression, start, length)  Stringexpression  The field or the value that will be use for the function to manipulate.  Start  Tells Access where in the stringexpression to start retrieving from  Length  The number of characters to extract. If the length is absent, then function will returns the rest of the string from where you start.
  • 19. Example on MID function Output: Middle of String Rest of String Computer Computer Studies Gaming a Gaming and Animation Techniques Computin Computing Info-Com Info-Comm Technology Informat Information Technology Network Network and CyberSecurity SELECT Mid(CourseDesp,12,8) As [Middle of String], Mid(CourseDesp,12) As [Rest of String] FROM course;
  • 20. INSTR Function Instr (start, stringexpression, search_string)  Start  Specify the position from which Access will start reading the stringexpression.  Stringexpression  The field or the value that will be use for searching.  Search_string  The value or the pattern that you looking for in the stringexpression
  • 21. Example on INSTR Function Output: CourseDesp Position of C Diploma In Computer Studies 12 Diploma in Gaming and Animation Techniques 35 Diploma In Computing 12 Diploma In Info-Comm Technology 17 Diploma In Information Technology 26 Diploma in Network and CyberSecurity 24 SELECT CourseDesp, Instr(1,CourseDesp,'C') As [Position of C] FROM course;
  • 22. LEFT / RIGHT Function Left (stringexpression, n) Or Right (stringexpression, n)  Stringexpression  The field or the value that will be use for manipulate.  n  The number of characters that will be returned from the stringexpression.
  • 23. Example on LEFT/RIGHT function SELECT MentorName, Left(MentorName,3) As [Left], Right(MentorName,3) As [Right] FROM Mentor; Output MentorName Left Right Goile Goi ile Rimes Rim mes Christopher Chr her Schubert Sch ert Norman Nor man Carroll Car oll
  • 24. TRIM Function Trim (stringexpression)  Stringexpression  The field or the value that spaces need to be removed
  • 25. Example on TRIM function SELECT TRIM(‘ Hello ’) As [Greetings] …. Output: Greetings Hello
  • 26. LEN Function Len (stringexpression)  Stringexpression  The field or the value that the length to be calculate.
  • 27. Example on LEN Function SELECT MentorName, Len(MentorName) As [Length] FROM Mentor; Output: MentorName Length Goile 5 Rimes 5 Christopher 11 Schubert 8 Norman 6 Carroll 7
  • 28. Using String Functions SELECT Mid(FirstName,1,Instr(1,FirstName,' ')) & ', ' & left(lastname,1) AS [Name] FROM Student; Output: Name Joseph , B Laura , K Choy , L Derrick , L Arthur , L Kathleen , M ………
  • 29. Summary  Must know the features of Single-Row functions.  Usage of both Text and Number functions.

Notas del editor

  1. Character Functions Single-row character functions accept character data as input and can return both character and number values. Character functions can be divided into: Case conversion functions: Convert the case of character strings Character manipulation functions: Perform operations of strings such as creating a substring This lesson covers the case conversion functions. Character manipulation functions are not covered in this course. Note: This list is a subset of the available character functions. For more information, see Oracle8 Server SQL Reference, “Character Functions.”