SlideShare uma empresa 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.

Mais conteúdo relacionado

Semelhante 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
 

Semelhante 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

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Último (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

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 do 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.”