6a SQL - Single Row Character Functions
6a SQL - Single Row Character Functions
WAH CAMPUS
06
Part-1
arg 1 Function
performs action
arg 2
Result
value
arg n
3 Prepared By: Amjad Usman (CUI, Wah)
Two Types of SQL Functions
Functions
Single-row Multiple-row
functions functions
Character
General Number
Single-row
functions
Conversion Date
Character
functions
Case-conversion Character-manipulation
functions functions
LOWER CONCAT
UPPER SUBSTR
INITCAP LENGTH
INSTR
LPAD | RPAD
TRIM
REPLACE
LOWER() function
converts a given character column, literal, or expression into
lowercase i.e. small letters.
UPPER() function
converts a given character column, literal, or expression into
uppercase, i.e. capital letters.
INITCAP() function
converts a given character column, literal, or expression into initial
case i.e. first letter of each word is capital.
Function Result
LOWER('SQL Course') sql course
UPPER(‘sql course') SQL COURSE
INITCAP(‘sql course') Sql Course
select lower(first_name),
upper(last_name),
initcap(job_id)
from employees;
Display the employee number, name, and department number for employee Higgins:
LENGTH tells the length of the characters entered into the column/field.
NOTE: Embedded spaces are counted.
In case, you omit the last parameter i.e. No. of characters then it will extract
all characters till end.
INSTR(source string, search item, [start position], [nth occurrence of search item])
Syntax
LPAD(string, length, [padstring])
Where:
String → source string
Length → an integer value that represents the final length of the
string returned (like field size)
Padstring → the character string to be used as padding
LPAD(salary 10 ‘*’)