SlideShare a Scribd company logo
1 of 188
DB2 SQL QUERY
By Hari Christian
Agenda
• Introduction to Database and SQL
• Basic SQL
• Advance SQL
What Is Database
• A database is an organized way of holding
together various pieces of information. The
term database actually refers to the
collection of data, not the means by which
it is stored.
• For a computer database, the software
used to manage the data is known as a
database-management system (DBMS).
What Is Database
• A filing cabinet and a telephone directory
both contain databases: They hold
information, organized in a structured
manner so that you can easily access the
individual item you want to find.
What Is Database
• A database consists of a series of tables.
Each table has a name, which is how it is
referenced in the SQL language. Each
database also has a name, and the same
RDBMS can manage many different
databases.
• DB2 is a multiuser database and can
restrict access to each database to only
specific users.
What Is Database
• A database table looks somewhat like a
spreadsheet: a set of rows and columns
that can contain data at each intersection.
In a relational database, you store different
types of data in different tables.
• For instance, the sample database in this
book has separate tables for customers,
products, and orders.
What Is Database
• Each table has a defined set of columns,
which determine the values it can store.
For example, the table that contains
information about products needs to store
a name, price, and weight for every
product.
• Each row of data can contain values for
only the columns defined in the table.
What Is Database
• In addition, each column is defined as a
particular data type, which determines the
kind of values it can store.
• The data type might restrict values to
numeric or date values, or it might impose
a maximum size.
What Is SQL
• The Structured Query Language (SQL) is
the most common way to retrieve and
manage database information.
• An SQL query consists of a series of
keywords that define the data set you want
to fetch from the database.
• SQL uses descriptive English keywords,
so most queries are easy to understand.
Retrieve Data
• The first SQL command you will learn, and
the one you will use most frequently, is
SELECT. In this lesson, you begin by
learning how to fetch data records from a
single table.
Retrieve Data
• A SELECT statement begins with the
SELECT keyword and is used to retrieve
information from database tables.
• You must specify the table name to fetch
data from, using the FROM keyword and
one or more columns that you want to
retrieve from that table.
Retrieve Data
• Query Format
SELECT [COLUMN_NAME]
FROM [TABLE_NAME];
Retrieve Single Column
• Display column NMDOSEN name from
table QRYLIB.AGSDOS
• SELECT NMDOSEN
FROM QRYLIB.AGSDOS;
Retrieve Multiple Column
• Display column KDDOSEN and
NMDOSEN name from table
QRYLIB.AGSDOS
• SELECT KDDOSEN, NMDOSEN
FROM QRYLIB.AGSDOS;
Retrieve All Column
• Display all column from table
QRYLIB.AGSDOS
• SELECT *
FROM QRYLIB.AGSDOS;
Retrieve Common Mistake
• File or table not found
• SELECT *
FROM QRYLIB.AGSDOSS;
Retrieve Common Mistake
• Column not in specified table
• SELECT NAME
FROM QRYLIB.AGSDOS;
Retrieve Exercise
• Retrieve Student Name from
QRYLIB.AGSMHS
• Retrieve Student ID and Student Name
from QRYLIB.AGSMHS
• Retrieve All column from
QRYLIB.AGSMHS
Retrieve Exercise
• Retrieve from QRYLIB.AGSMTKUL
• Retrieve from QRYLIB.AGSNIL
Filtering Data
• You can add a WHERE clause to a
SELECT statement to tell DB2 to filter the
query results based on a given rule.
• Rules in a WHERE clause refer to data
values returned by the query, and only
rows in which the values meet the criteria
in the rule are returned.
Filtering Data
• Query Format
SELECT [COLUMN_NAME]
FROM [TABLE_NAME]
WHERE [COLUMN_NAME] [OPERATOR]
[FILTER_CRITERIA];
Filtering Exact Value
• Display all information from lecturer D01
• SELECT *
FROM QRYLIB.AGSDOS
WHERE KDDOSEN = ‘D01’;
Filtering Except Value
• Display all lecturer information except
lecturer D01
• SELECT *
FROM QRYLIB.AGSDOS
WHERE KDDOSEN != ‘D01’;
Filtering Range Value
• Display student test with score equal 70
• SELECT *
FROM QRYLIB.AGSNIL
WHERE NILAI = 70;
Filtering Range Value
• Display student test with score greater
than 70
• SELECT *
FROM QRYLIB.AGSNIL
WHERE NILAI > 70;
Filtering Range Value
• Display student test with score greater
than or equal 70
• SELECT *
FROM QRYLIB.AGSNIL
WHERE NILAI >= 70;
Filtering Range Value
• Display student test with score less than
70
• SELECT *
FROM QRYLIB.AGSNIL
WHERE NILAI < 70;
Filtering Range Value
• Display student test with score less than or
equal 70
• SELECT *
FROM QRYLIB.AGSNIL
WHERE NILAI <= 70;
Filtering Common Mistake
• Missing quotes (filtering character requires
quotes)
• SELECT *
FROM QRYLIB.AGSDOS
WHERE KDDOSEN = D01;
Filtering Exercise
• Display all lecturer data with name start
with B
• Display all lecturer data with name start
with E
• Display lecturer D03 information
• Display student data score more than 50
• Display student data score more than or
equal 60
Ordering Data
• So far, you have seen that data is fetched
from the database in no particular order.
• To specify the sorting on the result of a
query, you can add an ORDER BY clause.
Ordering Data
• Query Format
SELECT [COLUMN_NAME]
FROM [TABLE_NAME]
ORDER BY [COLUMN_NAME];
Ordering Single Column
• Display all student information sort by
code
• SELECT *
FROM QRYLIB.AGSMHS
ORDER BY KDMHS;
Ordering Multiple Column
• Display all student information sort by
code and name
• SELECT *
FROM QRYLIB.AGSMHS
ORDER BY KDMHS, NMMHS;
Ordering Ascending
• Display all student information sort by
code (A-Z)
• SELECT *
FROM QRYLIB.AGSMHS
ORDER BY KDMHS ASC;
Ordering Descending
• Display all student information sort by
code (Z-A)
• SELECT *
FROM QRYLIB.AGSMHS
ORDER BY KDMHS DESC;
Ordering Exercise
• Display all student score with lowest score
to highest score (0 - 100)
• Display all student score with highest
score to lowest score (100 - 0)
• Display all student score with highest
score to lowest score (100 - 0) and sort by
student name (Z-A)
Advance Filtering
• The examples you have seen so far
perform filtering on a query based on only
a single condition.
• To provide greater control over a result
set, MySQL enables you to combine a
number of conditions in a WHERE clause.
• They are joined using the logical operator
keywords AND and OR.
Advance Filtering - AND
• Display student data with score greater
than or equal 70 and course id is M01
• SELECT *
FROM QRYLIB.AGSNIL
WHERE NILAI >= 70 AND KDMTK =
‘M01’;
Advance Filtering - OR
• Display student data with score greater
than or equal 70 or course id is M01
• SELECT *
FROM QRYLIB.AGSNIL
WHERE NILAI >= 70 OR KDMTK = ‘M01’;
Advance Filtering - IN
• Display lecture data D03 and D01
• SELECT *
FROM QRYLIB.AGSDOS
WHERE KDDOSEN IN ('D03', 'D01');
WHERE KDDOSEN = 'D03‘ AND
KDDOSEN = 'D01';
Advance Filtering – NOT IN
• Display lecture data except D03 and D01
• SELECT *
FROM QRYLIB.AGSDOS
WHERE KDDOSEN NOT IN ('D03', 'D01');
Advance Filtering – BETWEEN
• Display employees who were born
between 1920 - 1940
• SELECT *
FROM OL37V3COL.EMPLOYEE
WHERE BIRTHDATE BETWEEN '1920-
01-01' AND '1940-01-01';
Advance Filtering – Case
• Display employee bonus remark
• SELECT EMPNO, FIRSTNME, BONUS,
CASE
WHEN BONUS > 800 THEN 'BESAR'
WHEN BONUS > 400 THEN 'SEDANG'
ELSE 'KECIL'
END AS RANKING
FROM OL37V3COL.EMPLOYEE;
Precedence
• Display all manager with first name is
Michael or John (see if the result are
correct?)
• SELECT *
FROM OL37V3COL.EMPLOYEE
WHERE JOB = 'MANAGER' AND
FIRSTNME = 'Michael' OR FIRSTNME =
'John'
ORDER BY FIRSTNME;
Precedence
• Display all manager with first name is
Michael or John (see if the result are
correct?)
• SELECT *
FROM OL37V3COL.EMPLOYEE
WHERE JOB = 'MANAGER' AND
(FIRSTNME = 'Michael' OR FIRSTNME =
'John‘)
ORDER BY FIRSTNME;
Advance Filtering Exercise
• Display all manager with bonus more than
$500
• Display all employee with bonus more
than or equal $500
• Display all employee with salary more than
$20.000 and bonus more than $400 and
commision more than $100
• Display student grade
Limiting Data
• If you are expecting a query to still return
more rows that you want, even with the
filtering from a WHERE clause applied,
you can add a LIMIT clause to specify the
maximum number of records to be
returned.
Limiting Data
• Query Format
SELECT [COLUMN_NAME]
FROM [TABLE_NAME]
FETCH FIRST [NUMBER] ROWS ONLY;
Limiting Data
• Retrieve the first 5 data
• SELECT *
FROM OL37V3COL.EMPLOYEE
FETCH FIRST 5 ROWS ONLY;
Limiting Data Exercise
• Retrieve the first 25 employee data
• Retrieve the first 10 student data
• Retrieve the first 20 lecturer data
Numeric Function
• An expression that uses a numeric
operator can be used in a SQL statement
anywhere that you could otherwise put a
numeric value.
• You can also use a numeric operator to
modify retrieved data from a table, as long
as it is numeric data.
Numeric Function
• You can actually perform a query in SQL
without supplying a table name.
• This is useful only when you have an
expression as a selected value, but it can
be used to show the result of an
expression on fixed values.
Numeric Function
• Addition in SQL is performed using the +
operator, and subtraction using the -
operator. The following query shows an
expression using each of these operators:
• SELECT 15 + 28, 94 – 55
FROM SYSIBM.SYSDUMMY1;
Numeric Function – Column
• Display employee information and
additional calculated column salary +
100.000
• SELECT EMPNO, FIRSTNME,
LASTNAME, SALARY, SALARY + 100000
AS FUTURE_SALARY
FROM OL37V3COL.EMPLOYEE;
Numeric Function – Column
• Display employee information and
additional calculated column salary –
10.000
• SELECT EMPNO, FIRSTNME,
LASTNAME, SALARY, SALARY - 10000
FROM OL37V3COL.EMPLOYEE;
Numeric Function – Column
• Display employee information and
additional calculated column named tax
• SELECT EMPNO, FIRSTNME,
LASTNAME, SALARY, 0.1 * SALARY AS
TAX
FROM OL37V3COL.EMPLOYEE;
Numeric Function – Round
• Display employee information and
additional calculated rounding column (1
digit only)
• SELECT EMPNO, FIRSTNME,
LASTNAME, BONUS, ROUND(BONUS,
0)
FROM OL37V3COL.EMPLOYEE
ORDER BY EMPNO;
Numeric Function – Round
• Display employee information and
additional calculated rounding column (2
digit only)
• SELECT EMPNO, FIRSTNME,
LASTNAME, BONUS, ROUND(BONUS,
1)
FROM OL37V3COL.EMPLOYEE;
Numeric Function – Ceiling
• Display employee information and
additional calculated ceiling column
(forced to always round up)
• SELECT EMPNO, FIRSTNME,
LASTNAME, BONUS, CEILING(BONUS)
FROM OL37V3COL.EMPLOYEE;
Numeric Function – Floor
• Display employee information and
additional calculated ceiling column
(forced to always round down)
• SELECT EMPNO, FIRSTNME,
LASTNAME, BONUS, FLOOR(BONUS)
FROM OL37V3COL.EMPLOYEE;
Numeric Function – Pow
• Display pow function
• SELECT POW(2, 2)
FROM SYSIBM.SYSDUMMY1;
Numeric Function – Sqrt
• Display square root function
• SELECT SQRT(4)
FROM SYSIBM.SYSDUMMY1;
String Function - Like
• Display employee with last name contain
er
• SELECT *
FROM OL37V3COL.EMPLOYEE
WHERE LASTNAME LIKE '%er%';
String Function - Like
• Display employee with last name start with
Jo
• SELECT *
FROM OL37V3COL.EMPLOYEE
WHERE LASTNAME LIKE ‘Jo%';
String Function - Like
• Display employee with last name end with
Jo
• SELECT *
FROM OL37V3COL.EMPLOYEE
WHERE LASTNAME LIKE ‘%Jo';
String Function - Concat
• Display employee first name and last
name in one column
• SELECT CONCAT(FIRSTNME,
LASTNAME) AS COMPLETENAME
FROM OL37V3COL.EMPLOYEE;
String Function - Substring
• Display the first 5 letter from employee first
name
• SELECT SUBSTR(FIRSTNME, 1, 5) AS
SUBSTRING
FROM OL37V3COL.EMPLOYEE;
String Function – Upper case
• Display first name from employee in upper
case
• SELECT UCASE(FIRSTNME) AS
FIRSTNAME_UPPER
FROM OL37V3COL.EMPLOYEE;
String Function – Lower case
• Display first name from employee in lower
case
• SELECT LCASE(FIRSTNME) AS
FIRSTNAME_LOWER
FROM OL37V3COL.EMPLOYEE;
String Function – Replace
• Display last name from employee but if the
last name contain Jo then replace with XX
• SELECT REPLACE(LASTNAME, ‘Jo’,
‘XX’) AS LASTNAME_REPLACED
FROM OL37V3COL.EMPLOYEE;
Date Function – Current Date
• Display the current date
• SELECT CURDATE() AS
TANGGAL_SEKARANG
FROM SYSIBM.SYSDUMMY1;
Date Function – Current Time
• Display the current time
• SELECT CURTIME() AS
JAM_SEKARANG
FROM SYSIBM.SYSDUMMY1;
Date Function – Now
• Display the current time
• SELECT NOW() AS
CURRENT_DATE_TIME
FROM SYSIBM.SYSDUMMY1;
Date Function – Year
• Display the employee who were born in
1941
• SELECT *
FROM OL37V3COL.EMPLOYEE
WHERE YEAR(BIRTHDATE) = 1941;
Date Function – Month
• Display the employee who were born in
May
• SELECT *
FROM OL37V3COL.EMPLOYEE
WHERE MONTH(BIRTHDATE) = 05;
Date Function – Day
• Display the employee who were born 5th of
the month
• SELECT *
FROM OL37V3COL.EMPLOYEE
WHERE DAY(BIRTHDATE) = 05;
Summarizing Data
• SQL provides five aggregate functions that
enable you to summarize table data
without retrieving every row.
• By using these functions, you can find the
total number of rows in a dataset, the sum
of the values, or the highest, lowest, and
average values.
Summarizing Data - Count
• Count how many employee
• SELECT COUNT(*) AS
TOTAL_EMPLOYEE
FROM OL37V3COL.EMPLOYEE;
Summarizing Data - Sum
• Sum all employee salary
• SELECT SUM(SALARY) AS
TOTAL_SALARY
FROM OL37V3COL.EMPLOYEE;
Summarizing Data - Average
• Display average employee salary
• SELECT AVG(SALARY) AS
AVERAGE_SALARY
FROM OL37V3COL.EMPLOYEE;
Summarizing Data - Minimum
• Display minimum employee salary
• SELECT MIN(SALARY) AS
MINIMUM_SALARY
FROM OL37V3COL.EMPLOYEE;
Summarizing Data - Grouping
• Display employee per department
• SELECT JOB, COUNT(*) AS
TOTAL_EMPLOYEE
FROM OL37V3COL.EMPLOYEE
GROUP BY JOB;
Summarizing Data - Having
• Display employee per department with
more than 5 employee
• SELECT JOB, COUNT(*) AS
TOTAL_EMPLOYEE
FROM OL37V3COL.EMPLOYEE
GROUP BY JOB
HAVING COUNT(*) > 5;
Joining Data
• Define relationship between table and
Foreign Key
• For example relationship between NILAI
and MAHASISWA
Joining Data – Type of Join
• Inner Join
• Cross Join
• Self Join
• Left Join
• Right Join
Joining Data – Type of Join
Joining Data – Inner Join
• Join between NILAI and MAHASISWA
• SELECT *
FROM QRYLIB.AGSNIL n
INNER JOIN QRYLIB.AGSMHS m ON
n.KDMHS = m.KDMHS;
Joining Data – Left Join
• Join between NILAI and MAHASISWA
• SELECT *
FROM QRYLIB.AGSNIL n
LEFT JOIN QRYLIB.AGSMHS m ON
n.KDMHS = m.KDMHS;
Combining Data - Union
• Combine 2 query into 1 result
• SELECT *
FROM OL37V3COL.EMPLOYEE
WHERE LASTNAME LIKE '%er%‘
UNION
SELECT *
FROM OL37V3COL.EMPLOYEE
WHERE LASTNAME LIKE ‘%Jo%‘
List of Aggregate Functions
• AVG
The AVG function returns the average of a
set of numbers.
• CORRELATION
The CORRELATION function returns the
coefficient of the correlation of a set of
number pairs.
List of Aggregate Functions
• COUNT
The COUNT function returns the number
of rows or values in a set of rows or
values.
• COUNT_BIG
The COUNT_BIG function returns the
number of rows or values in a set of rows
or values. It is similar to COUNT except
that the result can be greater than the
maximum value of an integer.
List of Aggregate Functions
• COVARIANCE or COVARIANCE_SAMP
The COVARIANCE and
COVARIANCE_SAMP functions return the
covariance (population) of a set of number
pairs.
• MAX
The MAX function returns the maximum
value in a set of values.
List of Aggregate Functions
• MIN
The MIN function returns the minimum
value in a set of values.
• STDDEV or STDDEV_SAMP
The STDDEV or STDDEV_SAMP function
returns the standard deviation (/n), or the
sample standard deviation (/n-1), of a set
of numbers.
List of Aggregate Functions
• SUM
The SUM function returns the sum of a set
of numbers.
• VARIANCE or VARIANCE_SAMP
The VARIANCE function returns the
biased variance (/n) of a set of numbers.
The VARIANCE_SAMP function returns
the sample variance (/n-1) of a set of
numbers.
List of Aggregate Functions
• XMLAGG
The XMLAGG function returns an XML
sequence that contains an item for each
non-null value in a set of XML values.
List of Scalar Functions
• ABS
The ABS function returns the absolute
value of a number.
• ACOS
The ACOS function returns the arc cosine
of the argument as an angle, expressed in
radians. The ACOS and COS functions
are inverse operations.
List of Scalar Functions
• ADD_MONTHS
The ADD_MONTHS function returns a
date that represents expression plus a
specified number of months.
• ASCII
The ASCII function returns the leftmost
character of the argument as an integer.
List of Scalar Functions
• ASCII_CHR
The ASCII_CHR function returns the
character that has the ASCII code value
that is specified by the argument.
• ASCII_STR
The ASCII_STR function returns an ASCII
version of the string in the system ASCII
CCSID.
List of Scalar Functions
• ASIN
The ASIN function returns the arc sine of
the argument as an angle, expressed in
radians. The ASIN and SIN functions are
inverse operations.
• ATAN
The ATAN function returns the arc tangent
of the argument as an angle, expressed in
radians. The ATAN and TAN functions are
inverse operations.
List of Scalar Functions
• ATANH
The ATANH function returns the
hyperbolic arc tangent of a number,
expressed in radians. The ATANH and
TANH functions are inverse operations.
• ATAN2
The ATAN2 function returns the arc
tangent of x and y coordinates as an
angle, expressed in radians.
List of Scalar Functions
• BIGINT
The BIGINT function returns a big integer
representation of either a number or a
character or graphic string representation
of a number.
• BINARY
The BINARY function returns a BINARY
(fixed-length binary string) representation
of a string of any type or of a row ID type.
List of Scalar Functions
• BITAND, BITANDNOT, BITOR, BITXOR,
and BITNOT
The bit manipulation functions operate on
the twos complement representation of the
integer value of the input arguments. The
functions return the result as a
corresponding base 10 integer value in a
data type that is based on the data type of
the input arguments.
List of Scalar Functions
• BLOB
The BLOB function returns a BLOB
representation of a string of any type or of
a row ID type.
• CCSID_ENCODING
The CCSID_ENCODING function returns
a string value that indicates the encoding
scheme of a CCSID that is specified by
the argument.
List of Scalar Functions
• CEILING
The CEILING function returns the smallest
integer value that is greater than or equal
to the argument.
• CHAR
The CHAR function returns a fixed-length
character string representation of the
argument.
List of Scalar Functions
• CHARACTER_LENGTH
The CHARACTER_LENGTH function
returns the length of the first argument in
the specified string unit.
• CLOB
The CLOB function returns a CLOB
representation of a string.
List of Scalar Functions
• COALESCE
The COALESCE function returns the value
of the first nonnull expression.
• COLLATION_KEY
The COLLATION_KEY function returns a
varying-length binary string that represents
the collation key of the argument in the
specified collation.
List of Scalar Functions
• COMPARE_DECFLOAT
The COMPARE_DECFLOAT function
returns a SMALLINT value that indicates
whether the two arguments are equal or
unordered, or whether one argument is
greater than the other.
• CONCAT
The CONCAT function combines two
compatible string arguments.
List of Scalar Functions
• CONTAINS
The CONTAINS function searches a text
search index using criteria that are
specified in a search argument and returns
a result about whether or not a match was
found.
• COS
The COS function returns the cosine of the
argument, where the argument is an
angle, expressed in radians.
List of Scalar Functions
• COSH
The COSH function returns the hyperbolic
cosine of the argument, where the
argument is an angle, expressed in
radians.
• DATE
The DATE function returns a date that is
derived from a value.
List of Scalar Functions
• DAY
The DAY function returns the day part of a
value.
• DAYOFMONTH
The DAYOFMONTH function returns the
day part of a value.
List of Scalar Functions
• DAYOFWEEK
The DAYOFWEEK function returns an
integer, in the range of 1 to 7, that
represents the day of the week, where 1 is
Sunday and 7 is Saturday.
DAYOFWEEK_ISO
The DAYOFWEEK_ISO function returns
an integer, in the range of 1 to 7, that
represents the day of the week, where 1 is
Monday and 7 is Sunday.
List of Scalar Functions
• DAYOFYEAR
The DAYOFYEAR function returns an
integer, in the range of 1 to 366, that
represents the day of the year, where 1 is
January 1.
• DAYS
The DAYS function returns an integer
representation of a date.
List of Scalar Functions
• DBCLOB
The DBCLOB function returns a DBCLOB
representation of a character string value
• DECFLOAT
The DECFLOAT function returns a
decimal floating-point representation of
either a number or a character string
representation of a number.
List of Scalar Functions
• DECFLOAT_FORMAT
The DECFLOAT_FORMAT function
returns a DECFLOAT(34) value that is
based on the interpretation of the input
string using the specified format.
• DECFLOAT_SORTKEY
The DECFLOAT_SORTKEY function
returns a binary value that can be used
when sorting DECFLOAT values. The
sorting occurs in a manner that is
List of Scalar Functions
• DECIMAL or DEC
The DECIMAL function returns a decimal
representation of either a number or a
character-string or graphic-string
representation of a number, an integer, or
a decimal number.
• DECODE
The DECODE function compares each
expression2 to expression1. If expression1
is equal to expression2, or both
List of Scalar Functions
• DECRYPT_BINARY, DECRYPT_BIT,
DECRYPT_CHAR, and DECRYPT_DB
The decryption functions return a value
that is the result of decrypting encrypted
data. The decryption functions can decrypt
only values that are encrypted by using
the ENCRYPT_TDES function.
• DEGREES
The DEGREES function returns the
number of degrees of the argument, which
List of Scalar Functions
• DIFFERENCE
The DIFFERENCE function returns a
value, from 0 to 4, that represents the
difference between the sounds of two
strings, based on applying the SOUNDEX
function to the strings. A value of 4 is the
best possible sound match.
• DIGITS
The DIGITS function returns a character
string representation of the absolute value
List of Scalar Functions
• DOUBLE_PRECISION or DOUBLE
The DOUBLE_PRECISION and DOUBLE
functions returns a floating-point
representation of either a number or a
character-string or graphic-string
representation of a number, an integer, a
decimal number, or a floating-point
number.
• DSN_XMLVALIDATE
The DSN_XMLVALIDATE function returns
List of Scalar Functions
• EBCDIC_CHR
The EBCDIC_CHR function returns the
character that has the EBCDIC code value
that is specified by the argument.
• EBCDIC_STR
The EBCDIC_STR function returns a
string, in the system EBCDIC CCSID, that
is an EBCDIC version of the string.
List of Scalar Functions
• ENCRYPT_TDES
The ENCRYPT_TDES function returns a
value that is the result of encrypting the
first argument by using the Triple DES
encryption algorithm. The function can
also set the password that is used for
encryption.
• EXP
The EXP function returns a value that is
the base of the natural logarithm (e),
List of Scalar Functions
• EXTRACT
The EXTRACT function returns a portion
of a date or timestamp, based on its
arguments.
• FLOAT
The FLOAT function returns a floating-
point representation of either a number or
a string representation of a number.
FLOAT is a synonym for the DOUBLE
function.
List of Scalar Functions
• FLOOR
The FLOOR function returns the largest
integer value that is less than or equal to
the argument.
• GENERATE_UNIQUE
The GENERATE_UNIQUE function
returns a bit data character string that is
unique, compared to any other execution
of the same function.
List of Scalar Functions
• GETHINT
The GETHINT function returns a hint for
the password if a hint was embedded in
the encrypted data. A password hint is a
phrase that helps you remember the
password with which the data was
encrypted. For example, 'Ocean' might be
used as a hint to help remember the
password 'Pacific'.
• GETVARIABLE
List of Scalar Functions
• GRAPHIC
The GRAPHIC function returns a fixed-
length graphic-string representation of a
character string or a graphic string value,
depending on the type of the first
argument.
• HEX
The HEX function returns a hexadecimal
representation of a value.
List of Scalar Functions
• HOUR
The HOUR function returns the hour part
of a value.
• IDENTITY_VAL_LOCAL
The IDENTITY_VAL_LOCAL function
returns the most recently assigned value
for an identity column.
List of Scalar Functions
• IFNULL
The IFNULL function returns the first
nonnull expression.
• INSERT
The INSERT function returns a string
where, beginning at start in source-string,
length characters have been deleted and
insert-string has been inserted.
List of Scalar Functions
• INTEGER or INT
The INTEGER function returns an integer
representation of either a number or a
character string or graphic string
representation of an integer.
• JULIAN_DAY
The JULIAN_DAY function returns an
integer value that represents a number of
days from January 1, 4713 B.C. (the start
of the Julian date calendar) to the date
List of Scalar Functions
• LAST_DAY
The LAST_DAY scalar function returns a
date that represents the last day of the
month of the date argument.
• LCASE
The LCASE function returns a string in
which all the characters are converted to
lowercase characters.
List of Scalar Functions
• LEFT
The LEFT function returns a string that
consists of the specified number of
leftmost bytes of the specified string units.
• LENGTH
The LENGTH function returns the length
of a value.
List of Scalar Functions
• LN
The LN function returns the natural
logarithm of the argument. The LN and
EXP functions are inverse operations.
• LOCATE
The LOCATE function returns the position
at which the first occurrence of an
argument starts within another argument.
List of Scalar Functions
• LOCATE_IN_STRING
The LOCATE_IN_STRING function
returns the position at which an argument
starts within a specified string.
• LOG10
The LOG10 function returns the common
logarithm (base 10) of a number.
List of Scalar Functions
• LOWER
The LOWER function returns a string in
which all the characters are converted to
lowercase characters.
• LPAD
The LPAD function returns a string that is
composed of string-expression that is
padded on the left, with pad or blanks. The
LPAD function treats leading or trailing
blanks in string-expression as significant.
List of Scalar Functions
• LTRIM
The LTRIM function removes bytes from
the beginning of a string expression based
on the content of a trim expression.
• MAX
The MAX scalar function returns the
maximum value in a set of values.
List of Scalar Functions
• MICROSECOND
The MICROSECOND function returns the
microsecond part of a value.
• MIDNIGHT_SECONDS
The MIDNIGHT_SECONDS function
returns an integer, in the range of 0 to
86400, that represents the number of
seconds between midnight and the time
that is specified in the argument.
List of Scalar Functions
• MIN
The MIN scalar function returns the
minimum value in a set of values.
• MINUTE
The MINUTE function returns the minute
part of a value.
List of Scalar Functions
• MOD
The MOD function divides the first
argument by the second argument and
returns the remainder.
• MONTH
The MONTH function returns the month
part of a value.
List of Scalar Functions
• MONTHS_BETWEEN
The MONTHS_BETWEEN function
returns an estimate of the number of
months between two arguments.
• MQREAD
The MQREAD function returns a message
from a specified MQSeries® location
without removing the message from the
queue.
List of Scalar Functions
• MQREADCLOB
The MQREADCLOB function returns a
message from a specified MQSeries
location without removing the message
from the queue.
• MQRECEIVE
The MQRECEIVE function returns a
message from a specified MQSeries
location and removes the message from
the queue.
List of Scalar Functions
• MQRECEIVECLOB
The MQRECEIVECLOB function returns a
message from a specified MQSeries
location and removes the message from
the queue.
• MQSEND
The MQSEND function sends data to a
specified MQSeries location, and returns a
varying-length character string that
indicates whether the function was
List of Scalar Functions
• MULTIPLY_ALT
The MULTIPLY_ALT scalar function
returns the product of the two arguments.
This function is an alternative to the
multiplication operator and is especially
useful when the sum of the precisions of
the arguments exceeds 31.
• NEXT_DAY
The NEXT_DAY function returns a
datetime value that represents the first
List of Scalar Functions
• NORMALIZE_DECFLOAT
The NORMALIZE_DECFLOAT function
returns a DECFLOAT value that is the
result of the argument, set to its simplest
form. That is, a non-zero number that has
any trailing zeros in the coefficient has
those zeros removed by dividing the
coefficient by the appropriate power of ten
and adjusting the exponent accordingly. A
zero has its exponent set to 0.
List of Scalar Functions
• NORMALIZE_STRING
The NORMALIZE_STRING function takes
a Unicode string argument and returns a
normalized string that can be used for
comparison.
• NULLIF
The NULLIF function returns the null value
if the two arguments are equal; otherwise,
it returns the value of the first argument.
List of Scalar Functions
• NVL
The NVL function returns the first
argument that is not null.
• OVERLAY
The OVERLAY function returns a string
that is composed of one argument that is
inserted into another argument at the
same position where some number of
bytes have been deleted.
List of Scalar Functions
• PACK
The PACK function returns a binary string
value that contains a data type array and a
packed representation of each non-null
expression argument.
• POSITION
The POSITION function returns the
position of the first occurrence of an
argument within another argument, where
the position is expressed in terms of the
List of Scalar Functions
• POSSTR
The POSSTR function returns the position
of the first occurrence of an argument
within another argument.
• POWER
The POWER® function returns the value
of the first argument to the power of the
second argument.
List of Scalar Functions
• QUANTIZE
The QUANTIZE function returns a
DECFLOAT value that is equal in value
(except for any rounding) and sign to the
first argument and that has an exponent
that is set to equal the exponent of the
second argument.
• QUARTER
The QUARTER function returns an integer
between 1 and 4 that represents the
List of Scalar Functions
• RADIANS
The RADIANS function returns the number
of radians for an argument that is
expressed in degrees.
• RAISE_ERROR
The RAISE_ERROR function causes the
statement that invokes the function to
return an error with the specified
SQLSTATE (along with SQLCODE -438)
and error condition. The RAISE_ERROR
List of Scalar Functions
• RAND
The RAND function returns a random
floating-point value between 0 and 1. An
argument can be specified as an optional
seed value.
• REAL
The REAL function returns a single-
precision floating-point representation of
either a number or a string representation
of a number.
List of Scalar Functions
• REPEAT
The REPEAT function returns a character
string that is composed of an argument
that is repeated a specified number of
times.
• REPLACE
The REPLACE function replaces all
occurrences of search-string in source-
string with replace-string. If search-string
is not found in source-string, source-string
List of Scalar Functions
• RID
The RID function returns the record ID
(RID) of a row. The RID is used to
uniquely identify a row.
• RIGHT
The RIGHT function returns a string that
consists of the specified number of
rightmost bytes or specified string unit
from a string.
List of Scalar Functions
• ROUND
The ROUND function returns a number
that is rounded to the specified number of
places to the right or left of the decimal
place.
• ROUND_TIMESTAMP
The ROUND_TIMESTAMP scalar function
returns a timestamp that is rounded to the
unit that is specified by the timestamp
format string.
List of Scalar Functions
• ROWID
The ROWID function returns a row ID
representation of its argument.
• RPAD
The RPAD function returns a string that is
padded on the right with blanks or a
specified string.
List of Scalar Functions
• RTRIM
The RTRIM function removes bytes from
the end of a string expression based on
the content of a trim expression.
• SCORE
The SCORE function searches a text
search index using criteria that are
specified in a search argument and returns
a relevance score that measures how well
a document matches the query.
List of Scalar Functions
• SECOND
The SECOND function returns the
seconds part of a value with optional
fractional seconds.
• SIGN
The SIGN function returns an indicator of
the sign of the argument.
List of Scalar Functions
• SIN
The SIN function returns the sine of the
argument, where the argument is an
angle, expressed in radians.
• SINH
The SINH function returns the hyperbolic
sine of the argument, where the argument
is an angle, expressed in radians.
List of Scalar Functions
• SMALLINT
The SMALLINT function returns a small
integer representation either of a number
or of a string representation of a number.
• SOUNDEX
The SOUNDEX function returns a 4-
character code that represents the sound
of the words in the argument. The result
can be compared to the results of the
SOUNDEX function of other strings.
List of Scalar Functions
• SOAPHTTPC and SOAPHTTPV
The SOAPHTTPC function returns a
CLOB representation of XML data that
results from a SOAP request to the web
service that is specified by the first
argument. The SOAPHTTPV function
returns a VARCHAR representation of
XML data that results from a SOAP
request to the web service that is specified
by the first argument.
List of Scalar Functions
• SOAPHTTPNC and SOAPHTTPNV
The SOAPHTTPNC and SOAPHTTPNV
functions allow you to specify a complete
SOAP message as input and to return
complete SOAP messages from the
specified web service. The returned SOAP
messages are CLOB or VARCHAR
representations of the returned XML data.
List of Scalar Functions
• SPACE
The SPACE function returns a character
string that consists of the number of SBCS
blanks that the argument specifies.
• SQRT
The SQRT function returns the square root
of the argument.
List of Scalar Functions
• STRIP
The STRIP function removes blanks or
another specified character from the end,
the beginning, or both ends of a string
expression.
• SUBSTR
The SUBSTR function returns a substring
of a string.
List of Scalar Functions
• SUBSTRING
The SUBSTRING function returns a
substring of a string.
• TAN
The TAN function returns the tangent of
the argument, where the argument is an
angle, expressed in radians.
List of Scalar Functions
• TANH
The TANH function returns the hyperbolic
tangent of the argument, where the
argument is an angle, expressed in
radians.
• TIME
The TIME function returns a time that is
derived from a value.
List of Scalar Functions
• TIMESTAMP
The TIMESTAMP function returns a
TIMESTAMP WITHOUT TIME ZONE
value from its argument or arguments.
• TIMESTAMPADD
The TIMESTAMPADD function returns the
result of adding the specified number of
the designated interval to the timestamp
value.
List of Scalar Functions
• TIMESTAMP_FORMAT
The TIMESTAMP_FORMAT function
returns a TIMESTAMP WITHOUT TIME
ZONE value that is based on the
interpretation of the input string using the
specified format.
• TIMESTAMP_ISO
The TIMESTAMP_ISO function returns a
timestamp value that is based on a date, a
time, or a timestamp argument.
List of Scalar Functions
• TIMESTAMPDIFF
The TIMESTAMPDIFF function returns an
estimated number of intervals of the type
that is defined by the first argument, based
on the difference between two
timestamps.
• TIMESTAMP_TZ
The TIMESTAMP_TZ function returns a
TIMESTAMP WITH TIME ZONE value
from the input arguments.
List of Scalar Functions
• TO_CHAR
The TO_CHAR function returns a
character string representation of a
timestamp value that has been formatted
using a specified character template.
• TO_DATE
The TO_DATE function returns a
timestamp value that is based on the
interpretation of the input string using the
specified format.
List of Scalar Functions
• TO_NUMBER
The TO_NUMBER function returns a
DECFLOAT(34) value that is based on the
interpretation of the input string using the
specified format.
• TOTALORDER
The TOTALORDER function returns an
ordering for DECFLOAT values. The
TOTALORDER function returns a small
integer value that indicates how
List of Scalar Functions
• TRANSLATE
The TRANSLATE function returns a value
in which one or more characters of the first
argument might have been converted to
other characters.
• TRIM
The TRIM function removes bytes from the
beginning, from the end, or from both the
beginning and end of a string expression.
List of Scalar Functions
• TRUNCATE or TRUNC
The TRUNCATE function returns the first
argument, truncated as specified.
Truncation is to the number of places to
the right or left of the decimal point this is
specified by the second argument.
• TRUNC_TIMESTAMP
The TRUNC_TIMESTAMP function
returns a TIMESTAMP WITHOUT TIME
ZONE value that is the expression,
List of Scalar Functions
• UCASE
The UCASE function returns a string in
which all the characters have been
converted to uppercase characters. The
UCASE function is identical to the UPPER
function.
• UNICODE
The UNICODE function returns the
Unicode UTF-16 code value of the
leftmost character of the argument as an
List of Scalar Functions
• UNICODE_STR
The UNICODE_STR function returns a
string in Unicode UTF-8 or UTF-16,
depending on the specified option. The
string represents a Unicode encoding of
the input string.
• UPPER
The UPPER function returns a string in
which all the characters have been
converted to uppercase characters.
List of Scalar Functions
• VALUE
The VALUE function returns the value of
the first non-null expression.
• VARBINARY
The VARBINARY function returns a
VARBINARY (varying-length binary string)
representation of a string of any type.
List of Scalar Functions
• VARCHAR
The VARCHAR function returns a varying-
length character string representation of
the value specified by the first argument.
The first argument can be a character
string, a graphic string, a datetime value,
an integer number, a decimal number, a
floating-point number, or a row ID value.
List of Scalar Functions
• VARCHAR_FORMAT
The VARCHAR_FORMAT function returns
a character string representation of the
first argument in the format indicated by
format-string.
List of Scalar Functions
• VARGRAPHIC
The VARGRAPHIC function returns a
varying-length graphic string
representation of a the first argument. The
first argument can be a character string
value or a graphic string value.
• VERIFY_GROUP_FOR_USER
The VERIFY_GROUP_FOR_USER
function returns a value that indicates
whether the primary authorization ID and
List of Scalar Functions
• VERIFY_ROLE_FOR_USER
The VERIFY_ROLE_FOR_USER function
returns a value that indicates whether the
roles that are associated with the
authorization ID that is specified in the first
argument are included in the role names
that are specified in the list of the second
argument.
List of Scalar Functions
• VERIFY_TRUSTED_CONTEXT_ROLE_F
OR_USER
The
VERIFY_TRUSTED_CONTEXT_FOR_US
ER function returns a value that indicates
whether the authorization ID that is
associated with first argument has
acquired a role in a trusted connection and
whether that acquired role is included in
the role names that are specified in the list
List of Scalar Functions
• WEEK
The WEEK function returns an integer in
the range of 1 to 54 that represents the
week of the year. The week starts with
Sunday, and January 1 is always in the
first week.
• WEEK_ISO
The WEEK_ISO function returns an
integer in the range of 1 to 53 that
represents the week of the year. The week
List of Scalar Functions
• XMLATTRIBUTES
The XMLATTRIBUTES function constructs
XML attributes from the arguments. This
function can be used as an argument only
for the XMLELEMENT function.
• XMLCOMMENT
The XMLCOMMENT function returns an
XML value with a single comment node
from a string expression. The content of
the comment node is the value of the input
List of Scalar Functions
• XMLCONCAT
The XMLCONCAT function returns an
XML sequence that contains the
concatenation of a variable number of
XML input arguments.
• XMLDOCUMENT
The XMLDOCUMENT function returns an
XML value with a single document node
and zero or more nodes as its children.
The content of the generated XML
List of Scalar Functions
• XMLELEMENT
The XMLELEMENT function returns an
XML value that is an XML element node.
• XMLFOREST
The XMLFOREST function returns an
XML value that is a sequence of XML
element nodes.
• XMLMODIFY
The XMLMODIFY function returns an XML
value that might have been modified by
List of Scalar Functions
• XMLNAMESPACES
The XMLNAMESPACES function
constructs namespace declarations from
the arguments. This function can be used
as an argument only for specific functions,
such as the XMLELEMENT function and
the XMLFOREST function.
• XMLPARSE
The XMLPARSE function parses the
argument as an XML document and
List of Scalar Functions
• XMLPI
The XMLPI function returns an XML value
with a single processing instruction node.
• XMLQUERY
The XMLQUERY function returns an XML
value from the evaluation of an XQuery
expression, by using specified input
arguments, a context item, and XQuery
variables.
List of Scalar Functions
• XMLSERIALIZE
The XMLSERIALIZE function returns a
serialized XML value of the specified data
type that is generated from the first
argument.
• XMLTEXT
The XMLTEXT function returns an XML
value with a single text node that contains
the value of the argument.
List of Scalar Functions
• XMLXSROBJECTID
The XMLXSROBJECTID function returns
the XSR object identifier of the XML
schema that is used to validate the XML
document specified in the argument.
• XSLTRANSFORM
The XSLTRANSFORM function
transforms an XML document into a
different data format. The output can be
any form possible for the XSLT processor,
List of Scalar Functions
• YEAR
The YEAR function returns the year part of
a value that is a character or graphic
string. The value must be a valid string
representation of a date or timestamp.
Thank You

More Related Content

Similar to DB2 Sql Query

Similar to DB2 Sql Query (20)

filterAndSort.pptx
filterAndSort.pptxfilterAndSort.pptx
filterAndSort.pptx
 
ADBMS - Joins , Sorting , Distributed Database Systems
ADBMS - Joins , Sorting , Distributed Database SystemsADBMS - Joins , Sorting , Distributed Database Systems
ADBMS - Joins , Sorting , Distributed Database Systems
 
Oracle Forms: Data Blocks on Different Sources
Oracle Forms: Data Blocks on Different SourcesOracle Forms: Data Blocks on Different Sources
Oracle Forms: Data Blocks on Different Sources
 
SQL
SQLSQL
SQL
 
Ms sql-server
Ms sql-serverMs sql-server
Ms sql-server
 
Dbms sql-final
Dbms  sql-finalDbms  sql-final
Dbms sql-final
 
SQL(database)
SQL(database)SQL(database)
SQL(database)
 
Tk2323 lecture 7 sql
Tk2323 lecture 7   sql Tk2323 lecture 7   sql
Tk2323 lecture 7 sql
 
MySQL basics
MySQL basicsMySQL basics
MySQL basics
 
Data Base Management System Lecture 10.pdf
Data Base Management System Lecture 10.pdfData Base Management System Lecture 10.pdf
Data Base Management System Lecture 10.pdf
 
IR SQLite Session #1
IR SQLite Session #1IR SQLite Session #1
IR SQLite Session #1
 
SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data   SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data
 
ms-sql-server-150223140402-conversion-gate02.pptx
ms-sql-server-150223140402-conversion-gate02.pptxms-sql-server-150223140402-conversion-gate02.pptx
ms-sql-server-150223140402-conversion-gate02.pptx
 
Access 03
Access 03Access 03
Access 03
 
SQL
SQLSQL
SQL
 
Lab
LabLab
Lab
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
 
Querying_with_T-SQL_-_01.pptx
Querying_with_T-SQL_-_01.pptxQuerying_with_T-SQL_-_01.pptx
Querying_with_T-SQL_-_01.pptx
 
Oracle 12c New Features for Developers
Oracle 12c New Features for DevelopersOracle 12c New Features for Developers
Oracle 12c New Features for Developers
 
Dbms
DbmsDbms
Dbms
 

More from Hari Christian

06 Java Language And OOP Part VI
06 Java Language And OOP Part VI06 Java Language And OOP Part VI
06 Java Language And OOP Part VIHari Christian
 
01 Java Language And OOP Part I LAB
01 Java Language And OOP Part I LAB01 Java Language And OOP Part I LAB
01 Java Language And OOP Part I LABHari Christian
 
02 Java Language And OOP Part II LAB
02 Java Language And OOP Part II LAB02 Java Language And OOP Part II LAB
02 Java Language And OOP Part II LABHari Christian
 
05 Java Language And OOP Part V
05 Java Language And OOP Part V05 Java Language And OOP Part V
05 Java Language And OOP Part VHari Christian
 
03 Java Language And OOP Part III
03 Java Language And OOP Part III03 Java Language And OOP Part III
03 Java Language And OOP Part IIIHari Christian
 
04 Java Language And OOP Part IV
04 Java Language And OOP Part IV04 Java Language And OOP Part IV
04 Java Language And OOP Part IVHari Christian
 
02 Java Language And OOP PART II
02 Java Language And OOP PART II02 Java Language And OOP PART II
02 Java Language And OOP PART IIHari Christian
 
01 Java Language And OOP PART I
01 Java Language And OOP PART I01 Java Language And OOP PART I
01 Java Language And OOP PART IHari Christian
 
MM38 kelas B Six Sigma
MM38 kelas B Six SigmaMM38 kelas B Six Sigma
MM38 kelas B Six SigmaHari Christian
 

More from Hari Christian (10)

HARI CV AND RESUME
HARI CV AND RESUMEHARI CV AND RESUME
HARI CV AND RESUME
 
06 Java Language And OOP Part VI
06 Java Language And OOP Part VI06 Java Language And OOP Part VI
06 Java Language And OOP Part VI
 
01 Java Language And OOP Part I LAB
01 Java Language And OOP Part I LAB01 Java Language And OOP Part I LAB
01 Java Language And OOP Part I LAB
 
02 Java Language And OOP Part II LAB
02 Java Language And OOP Part II LAB02 Java Language And OOP Part II LAB
02 Java Language And OOP Part II LAB
 
05 Java Language And OOP Part V
05 Java Language And OOP Part V05 Java Language And OOP Part V
05 Java Language And OOP Part V
 
03 Java Language And OOP Part III
03 Java Language And OOP Part III03 Java Language And OOP Part III
03 Java Language And OOP Part III
 
04 Java Language And OOP Part IV
04 Java Language And OOP Part IV04 Java Language And OOP Part IV
04 Java Language And OOP Part IV
 
02 Java Language And OOP PART II
02 Java Language And OOP PART II02 Java Language And OOP PART II
02 Java Language And OOP PART II
 
01 Java Language And OOP PART I
01 Java Language And OOP PART I01 Java Language And OOP PART I
01 Java Language And OOP PART I
 
MM38 kelas B Six Sigma
MM38 kelas B Six SigmaMM38 kelas B Six Sigma
MM38 kelas B Six Sigma
 

Recently uploaded

Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutionsmonugehlot87
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 

Recently uploaded (20)

Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutions
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 

DB2 Sql Query

  • 1. DB2 SQL QUERY By Hari Christian
  • 2. Agenda • Introduction to Database and SQL • Basic SQL • Advance SQL
  • 3. What Is Database • A database is an organized way of holding together various pieces of information. The term database actually refers to the collection of data, not the means by which it is stored. • For a computer database, the software used to manage the data is known as a database-management system (DBMS).
  • 4. What Is Database • A filing cabinet and a telephone directory both contain databases: They hold information, organized in a structured manner so that you can easily access the individual item you want to find.
  • 5. What Is Database • A database consists of a series of tables. Each table has a name, which is how it is referenced in the SQL language. Each database also has a name, and the same RDBMS can manage many different databases. • DB2 is a multiuser database and can restrict access to each database to only specific users.
  • 6. What Is Database • A database table looks somewhat like a spreadsheet: a set of rows and columns that can contain data at each intersection. In a relational database, you store different types of data in different tables. • For instance, the sample database in this book has separate tables for customers, products, and orders.
  • 7. What Is Database • Each table has a defined set of columns, which determine the values it can store. For example, the table that contains information about products needs to store a name, price, and weight for every product. • Each row of data can contain values for only the columns defined in the table.
  • 8. What Is Database • In addition, each column is defined as a particular data type, which determines the kind of values it can store. • The data type might restrict values to numeric or date values, or it might impose a maximum size.
  • 9. What Is SQL • The Structured Query Language (SQL) is the most common way to retrieve and manage database information. • An SQL query consists of a series of keywords that define the data set you want to fetch from the database. • SQL uses descriptive English keywords, so most queries are easy to understand.
  • 10. Retrieve Data • The first SQL command you will learn, and the one you will use most frequently, is SELECT. In this lesson, you begin by learning how to fetch data records from a single table.
  • 11. Retrieve Data • A SELECT statement begins with the SELECT keyword and is used to retrieve information from database tables. • You must specify the table name to fetch data from, using the FROM keyword and one or more columns that you want to retrieve from that table.
  • 12. Retrieve Data • Query Format SELECT [COLUMN_NAME] FROM [TABLE_NAME];
  • 13. Retrieve Single Column • Display column NMDOSEN name from table QRYLIB.AGSDOS • SELECT NMDOSEN FROM QRYLIB.AGSDOS;
  • 14. Retrieve Multiple Column • Display column KDDOSEN and NMDOSEN name from table QRYLIB.AGSDOS • SELECT KDDOSEN, NMDOSEN FROM QRYLIB.AGSDOS;
  • 15. Retrieve All Column • Display all column from table QRYLIB.AGSDOS • SELECT * FROM QRYLIB.AGSDOS;
  • 16. Retrieve Common Mistake • File or table not found • SELECT * FROM QRYLIB.AGSDOSS;
  • 17. Retrieve Common Mistake • Column not in specified table • SELECT NAME FROM QRYLIB.AGSDOS;
  • 18. Retrieve Exercise • Retrieve Student Name from QRYLIB.AGSMHS • Retrieve Student ID and Student Name from QRYLIB.AGSMHS • Retrieve All column from QRYLIB.AGSMHS
  • 19. Retrieve Exercise • Retrieve from QRYLIB.AGSMTKUL • Retrieve from QRYLIB.AGSNIL
  • 20. Filtering Data • You can add a WHERE clause to a SELECT statement to tell DB2 to filter the query results based on a given rule. • Rules in a WHERE clause refer to data values returned by the query, and only rows in which the values meet the criteria in the rule are returned.
  • 21. Filtering Data • Query Format SELECT [COLUMN_NAME] FROM [TABLE_NAME] WHERE [COLUMN_NAME] [OPERATOR] [FILTER_CRITERIA];
  • 22. Filtering Exact Value • Display all information from lecturer D01 • SELECT * FROM QRYLIB.AGSDOS WHERE KDDOSEN = ‘D01’;
  • 23. Filtering Except Value • Display all lecturer information except lecturer D01 • SELECT * FROM QRYLIB.AGSDOS WHERE KDDOSEN != ‘D01’;
  • 24. Filtering Range Value • Display student test with score equal 70 • SELECT * FROM QRYLIB.AGSNIL WHERE NILAI = 70;
  • 25. Filtering Range Value • Display student test with score greater than 70 • SELECT * FROM QRYLIB.AGSNIL WHERE NILAI > 70;
  • 26. Filtering Range Value • Display student test with score greater than or equal 70 • SELECT * FROM QRYLIB.AGSNIL WHERE NILAI >= 70;
  • 27. Filtering Range Value • Display student test with score less than 70 • SELECT * FROM QRYLIB.AGSNIL WHERE NILAI < 70;
  • 28. Filtering Range Value • Display student test with score less than or equal 70 • SELECT * FROM QRYLIB.AGSNIL WHERE NILAI <= 70;
  • 29. Filtering Common Mistake • Missing quotes (filtering character requires quotes) • SELECT * FROM QRYLIB.AGSDOS WHERE KDDOSEN = D01;
  • 30. Filtering Exercise • Display all lecturer data with name start with B • Display all lecturer data with name start with E • Display lecturer D03 information • Display student data score more than 50 • Display student data score more than or equal 60
  • 31. Ordering Data • So far, you have seen that data is fetched from the database in no particular order. • To specify the sorting on the result of a query, you can add an ORDER BY clause.
  • 32. Ordering Data • Query Format SELECT [COLUMN_NAME] FROM [TABLE_NAME] ORDER BY [COLUMN_NAME];
  • 33. Ordering Single Column • Display all student information sort by code • SELECT * FROM QRYLIB.AGSMHS ORDER BY KDMHS;
  • 34. Ordering Multiple Column • Display all student information sort by code and name • SELECT * FROM QRYLIB.AGSMHS ORDER BY KDMHS, NMMHS;
  • 35. Ordering Ascending • Display all student information sort by code (A-Z) • SELECT * FROM QRYLIB.AGSMHS ORDER BY KDMHS ASC;
  • 36. Ordering Descending • Display all student information sort by code (Z-A) • SELECT * FROM QRYLIB.AGSMHS ORDER BY KDMHS DESC;
  • 37. Ordering Exercise • Display all student score with lowest score to highest score (0 - 100) • Display all student score with highest score to lowest score (100 - 0) • Display all student score with highest score to lowest score (100 - 0) and sort by student name (Z-A)
  • 38. Advance Filtering • The examples you have seen so far perform filtering on a query based on only a single condition. • To provide greater control over a result set, MySQL enables you to combine a number of conditions in a WHERE clause. • They are joined using the logical operator keywords AND and OR.
  • 39. Advance Filtering - AND • Display student data with score greater than or equal 70 and course id is M01 • SELECT * FROM QRYLIB.AGSNIL WHERE NILAI >= 70 AND KDMTK = ‘M01’;
  • 40. Advance Filtering - OR • Display student data with score greater than or equal 70 or course id is M01 • SELECT * FROM QRYLIB.AGSNIL WHERE NILAI >= 70 OR KDMTK = ‘M01’;
  • 41. Advance Filtering - IN • Display lecture data D03 and D01 • SELECT * FROM QRYLIB.AGSDOS WHERE KDDOSEN IN ('D03', 'D01'); WHERE KDDOSEN = 'D03‘ AND KDDOSEN = 'D01';
  • 42. Advance Filtering – NOT IN • Display lecture data except D03 and D01 • SELECT * FROM QRYLIB.AGSDOS WHERE KDDOSEN NOT IN ('D03', 'D01');
  • 43. Advance Filtering – BETWEEN • Display employees who were born between 1920 - 1940 • SELECT * FROM OL37V3COL.EMPLOYEE WHERE BIRTHDATE BETWEEN '1920- 01-01' AND '1940-01-01';
  • 44. Advance Filtering – Case • Display employee bonus remark • SELECT EMPNO, FIRSTNME, BONUS, CASE WHEN BONUS > 800 THEN 'BESAR' WHEN BONUS > 400 THEN 'SEDANG' ELSE 'KECIL' END AS RANKING FROM OL37V3COL.EMPLOYEE;
  • 45. Precedence • Display all manager with first name is Michael or John (see if the result are correct?) • SELECT * FROM OL37V3COL.EMPLOYEE WHERE JOB = 'MANAGER' AND FIRSTNME = 'Michael' OR FIRSTNME = 'John' ORDER BY FIRSTNME;
  • 46. Precedence • Display all manager with first name is Michael or John (see if the result are correct?) • SELECT * FROM OL37V3COL.EMPLOYEE WHERE JOB = 'MANAGER' AND (FIRSTNME = 'Michael' OR FIRSTNME = 'John‘) ORDER BY FIRSTNME;
  • 47. Advance Filtering Exercise • Display all manager with bonus more than $500 • Display all employee with bonus more than or equal $500 • Display all employee with salary more than $20.000 and bonus more than $400 and commision more than $100 • Display student grade
  • 48. Limiting Data • If you are expecting a query to still return more rows that you want, even with the filtering from a WHERE clause applied, you can add a LIMIT clause to specify the maximum number of records to be returned.
  • 49. Limiting Data • Query Format SELECT [COLUMN_NAME] FROM [TABLE_NAME] FETCH FIRST [NUMBER] ROWS ONLY;
  • 50. Limiting Data • Retrieve the first 5 data • SELECT * FROM OL37V3COL.EMPLOYEE FETCH FIRST 5 ROWS ONLY;
  • 51. Limiting Data Exercise • Retrieve the first 25 employee data • Retrieve the first 10 student data • Retrieve the first 20 lecturer data
  • 52. Numeric Function • An expression that uses a numeric operator can be used in a SQL statement anywhere that you could otherwise put a numeric value. • You can also use a numeric operator to modify retrieved data from a table, as long as it is numeric data.
  • 53. Numeric Function • You can actually perform a query in SQL without supplying a table name. • This is useful only when you have an expression as a selected value, but it can be used to show the result of an expression on fixed values.
  • 54. Numeric Function • Addition in SQL is performed using the + operator, and subtraction using the - operator. The following query shows an expression using each of these operators: • SELECT 15 + 28, 94 – 55 FROM SYSIBM.SYSDUMMY1;
  • 55. Numeric Function – Column • Display employee information and additional calculated column salary + 100.000 • SELECT EMPNO, FIRSTNME, LASTNAME, SALARY, SALARY + 100000 AS FUTURE_SALARY FROM OL37V3COL.EMPLOYEE;
  • 56. Numeric Function – Column • Display employee information and additional calculated column salary – 10.000 • SELECT EMPNO, FIRSTNME, LASTNAME, SALARY, SALARY - 10000 FROM OL37V3COL.EMPLOYEE;
  • 57. Numeric Function – Column • Display employee information and additional calculated column named tax • SELECT EMPNO, FIRSTNME, LASTNAME, SALARY, 0.1 * SALARY AS TAX FROM OL37V3COL.EMPLOYEE;
  • 58. Numeric Function – Round • Display employee information and additional calculated rounding column (1 digit only) • SELECT EMPNO, FIRSTNME, LASTNAME, BONUS, ROUND(BONUS, 0) FROM OL37V3COL.EMPLOYEE ORDER BY EMPNO;
  • 59. Numeric Function – Round • Display employee information and additional calculated rounding column (2 digit only) • SELECT EMPNO, FIRSTNME, LASTNAME, BONUS, ROUND(BONUS, 1) FROM OL37V3COL.EMPLOYEE;
  • 60. Numeric Function – Ceiling • Display employee information and additional calculated ceiling column (forced to always round up) • SELECT EMPNO, FIRSTNME, LASTNAME, BONUS, CEILING(BONUS) FROM OL37V3COL.EMPLOYEE;
  • 61. Numeric Function – Floor • Display employee information and additional calculated ceiling column (forced to always round down) • SELECT EMPNO, FIRSTNME, LASTNAME, BONUS, FLOOR(BONUS) FROM OL37V3COL.EMPLOYEE;
  • 62. Numeric Function – Pow • Display pow function • SELECT POW(2, 2) FROM SYSIBM.SYSDUMMY1;
  • 63. Numeric Function – Sqrt • Display square root function • SELECT SQRT(4) FROM SYSIBM.SYSDUMMY1;
  • 64. String Function - Like • Display employee with last name contain er • SELECT * FROM OL37V3COL.EMPLOYEE WHERE LASTNAME LIKE '%er%';
  • 65. String Function - Like • Display employee with last name start with Jo • SELECT * FROM OL37V3COL.EMPLOYEE WHERE LASTNAME LIKE ‘Jo%';
  • 66. String Function - Like • Display employee with last name end with Jo • SELECT * FROM OL37V3COL.EMPLOYEE WHERE LASTNAME LIKE ‘%Jo';
  • 67. String Function - Concat • Display employee first name and last name in one column • SELECT CONCAT(FIRSTNME, LASTNAME) AS COMPLETENAME FROM OL37V3COL.EMPLOYEE;
  • 68. String Function - Substring • Display the first 5 letter from employee first name • SELECT SUBSTR(FIRSTNME, 1, 5) AS SUBSTRING FROM OL37V3COL.EMPLOYEE;
  • 69. String Function – Upper case • Display first name from employee in upper case • SELECT UCASE(FIRSTNME) AS FIRSTNAME_UPPER FROM OL37V3COL.EMPLOYEE;
  • 70. String Function – Lower case • Display first name from employee in lower case • SELECT LCASE(FIRSTNME) AS FIRSTNAME_LOWER FROM OL37V3COL.EMPLOYEE;
  • 71. String Function – Replace • Display last name from employee but if the last name contain Jo then replace with XX • SELECT REPLACE(LASTNAME, ‘Jo’, ‘XX’) AS LASTNAME_REPLACED FROM OL37V3COL.EMPLOYEE;
  • 72. Date Function – Current Date • Display the current date • SELECT CURDATE() AS TANGGAL_SEKARANG FROM SYSIBM.SYSDUMMY1;
  • 73. Date Function – Current Time • Display the current time • SELECT CURTIME() AS JAM_SEKARANG FROM SYSIBM.SYSDUMMY1;
  • 74. Date Function – Now • Display the current time • SELECT NOW() AS CURRENT_DATE_TIME FROM SYSIBM.SYSDUMMY1;
  • 75. Date Function – Year • Display the employee who were born in 1941 • SELECT * FROM OL37V3COL.EMPLOYEE WHERE YEAR(BIRTHDATE) = 1941;
  • 76. Date Function – Month • Display the employee who were born in May • SELECT * FROM OL37V3COL.EMPLOYEE WHERE MONTH(BIRTHDATE) = 05;
  • 77. Date Function – Day • Display the employee who were born 5th of the month • SELECT * FROM OL37V3COL.EMPLOYEE WHERE DAY(BIRTHDATE) = 05;
  • 78. Summarizing Data • SQL provides five aggregate functions that enable you to summarize table data without retrieving every row. • By using these functions, you can find the total number of rows in a dataset, the sum of the values, or the highest, lowest, and average values.
  • 79. Summarizing Data - Count • Count how many employee • SELECT COUNT(*) AS TOTAL_EMPLOYEE FROM OL37V3COL.EMPLOYEE;
  • 80. Summarizing Data - Sum • Sum all employee salary • SELECT SUM(SALARY) AS TOTAL_SALARY FROM OL37V3COL.EMPLOYEE;
  • 81. Summarizing Data - Average • Display average employee salary • SELECT AVG(SALARY) AS AVERAGE_SALARY FROM OL37V3COL.EMPLOYEE;
  • 82. Summarizing Data - Minimum • Display minimum employee salary • SELECT MIN(SALARY) AS MINIMUM_SALARY FROM OL37V3COL.EMPLOYEE;
  • 83. Summarizing Data - Grouping • Display employee per department • SELECT JOB, COUNT(*) AS TOTAL_EMPLOYEE FROM OL37V3COL.EMPLOYEE GROUP BY JOB;
  • 84. Summarizing Data - Having • Display employee per department with more than 5 employee • SELECT JOB, COUNT(*) AS TOTAL_EMPLOYEE FROM OL37V3COL.EMPLOYEE GROUP BY JOB HAVING COUNT(*) > 5;
  • 85. Joining Data • Define relationship between table and Foreign Key • For example relationship between NILAI and MAHASISWA
  • 86. Joining Data – Type of Join • Inner Join • Cross Join • Self Join • Left Join • Right Join
  • 87. Joining Data – Type of Join
  • 88. Joining Data – Inner Join • Join between NILAI and MAHASISWA • SELECT * FROM QRYLIB.AGSNIL n INNER JOIN QRYLIB.AGSMHS m ON n.KDMHS = m.KDMHS;
  • 89. Joining Data – Left Join • Join between NILAI and MAHASISWA • SELECT * FROM QRYLIB.AGSNIL n LEFT JOIN QRYLIB.AGSMHS m ON n.KDMHS = m.KDMHS;
  • 90. Combining Data - Union • Combine 2 query into 1 result • SELECT * FROM OL37V3COL.EMPLOYEE WHERE LASTNAME LIKE '%er%‘ UNION SELECT * FROM OL37V3COL.EMPLOYEE WHERE LASTNAME LIKE ‘%Jo%‘
  • 91. List of Aggregate Functions • AVG The AVG function returns the average of a set of numbers. • CORRELATION The CORRELATION function returns the coefficient of the correlation of a set of number pairs.
  • 92. List of Aggregate Functions • COUNT The COUNT function returns the number of rows or values in a set of rows or values. • COUNT_BIG The COUNT_BIG function returns the number of rows or values in a set of rows or values. It is similar to COUNT except that the result can be greater than the maximum value of an integer.
  • 93. List of Aggregate Functions • COVARIANCE or COVARIANCE_SAMP The COVARIANCE and COVARIANCE_SAMP functions return the covariance (population) of a set of number pairs. • MAX The MAX function returns the maximum value in a set of values.
  • 94. List of Aggregate Functions • MIN The MIN function returns the minimum value in a set of values. • STDDEV or STDDEV_SAMP The STDDEV or STDDEV_SAMP function returns the standard deviation (/n), or the sample standard deviation (/n-1), of a set of numbers.
  • 95. List of Aggregate Functions • SUM The SUM function returns the sum of a set of numbers. • VARIANCE or VARIANCE_SAMP The VARIANCE function returns the biased variance (/n) of a set of numbers. The VARIANCE_SAMP function returns the sample variance (/n-1) of a set of numbers.
  • 96. List of Aggregate Functions • XMLAGG The XMLAGG function returns an XML sequence that contains an item for each non-null value in a set of XML values.
  • 97. List of Scalar Functions • ABS The ABS function returns the absolute value of a number. • ACOS The ACOS function returns the arc cosine of the argument as an angle, expressed in radians. The ACOS and COS functions are inverse operations.
  • 98. List of Scalar Functions • ADD_MONTHS The ADD_MONTHS function returns a date that represents expression plus a specified number of months. • ASCII The ASCII function returns the leftmost character of the argument as an integer.
  • 99. List of Scalar Functions • ASCII_CHR The ASCII_CHR function returns the character that has the ASCII code value that is specified by the argument. • ASCII_STR The ASCII_STR function returns an ASCII version of the string in the system ASCII CCSID.
  • 100. List of Scalar Functions • ASIN The ASIN function returns the arc sine of the argument as an angle, expressed in radians. The ASIN and SIN functions are inverse operations. • ATAN The ATAN function returns the arc tangent of the argument as an angle, expressed in radians. The ATAN and TAN functions are inverse operations.
  • 101. List of Scalar Functions • ATANH The ATANH function returns the hyperbolic arc tangent of a number, expressed in radians. The ATANH and TANH functions are inverse operations. • ATAN2 The ATAN2 function returns the arc tangent of x and y coordinates as an angle, expressed in radians.
  • 102. List of Scalar Functions • BIGINT The BIGINT function returns a big integer representation of either a number or a character or graphic string representation of a number. • BINARY The BINARY function returns a BINARY (fixed-length binary string) representation of a string of any type or of a row ID type.
  • 103. List of Scalar Functions • BITAND, BITANDNOT, BITOR, BITXOR, and BITNOT The bit manipulation functions operate on the twos complement representation of the integer value of the input arguments. The functions return the result as a corresponding base 10 integer value in a data type that is based on the data type of the input arguments.
  • 104. List of Scalar Functions • BLOB The BLOB function returns a BLOB representation of a string of any type or of a row ID type. • CCSID_ENCODING The CCSID_ENCODING function returns a string value that indicates the encoding scheme of a CCSID that is specified by the argument.
  • 105. List of Scalar Functions • CEILING The CEILING function returns the smallest integer value that is greater than or equal to the argument. • CHAR The CHAR function returns a fixed-length character string representation of the argument.
  • 106. List of Scalar Functions • CHARACTER_LENGTH The CHARACTER_LENGTH function returns the length of the first argument in the specified string unit. • CLOB The CLOB function returns a CLOB representation of a string.
  • 107. List of Scalar Functions • COALESCE The COALESCE function returns the value of the first nonnull expression. • COLLATION_KEY The COLLATION_KEY function returns a varying-length binary string that represents the collation key of the argument in the specified collation.
  • 108. List of Scalar Functions • COMPARE_DECFLOAT The COMPARE_DECFLOAT function returns a SMALLINT value that indicates whether the two arguments are equal or unordered, or whether one argument is greater than the other. • CONCAT The CONCAT function combines two compatible string arguments.
  • 109. List of Scalar Functions • CONTAINS The CONTAINS function searches a text search index using criteria that are specified in a search argument and returns a result about whether or not a match was found. • COS The COS function returns the cosine of the argument, where the argument is an angle, expressed in radians.
  • 110. List of Scalar Functions • COSH The COSH function returns the hyperbolic cosine of the argument, where the argument is an angle, expressed in radians. • DATE The DATE function returns a date that is derived from a value.
  • 111. List of Scalar Functions • DAY The DAY function returns the day part of a value. • DAYOFMONTH The DAYOFMONTH function returns the day part of a value.
  • 112. List of Scalar Functions • DAYOFWEEK The DAYOFWEEK function returns an integer, in the range of 1 to 7, that represents the day of the week, where 1 is Sunday and 7 is Saturday. DAYOFWEEK_ISO The DAYOFWEEK_ISO function returns an integer, in the range of 1 to 7, that represents the day of the week, where 1 is Monday and 7 is Sunday.
  • 113. List of Scalar Functions • DAYOFYEAR The DAYOFYEAR function returns an integer, in the range of 1 to 366, that represents the day of the year, where 1 is January 1. • DAYS The DAYS function returns an integer representation of a date.
  • 114. List of Scalar Functions • DBCLOB The DBCLOB function returns a DBCLOB representation of a character string value • DECFLOAT The DECFLOAT function returns a decimal floating-point representation of either a number or a character string representation of a number.
  • 115. List of Scalar Functions • DECFLOAT_FORMAT The DECFLOAT_FORMAT function returns a DECFLOAT(34) value that is based on the interpretation of the input string using the specified format. • DECFLOAT_SORTKEY The DECFLOAT_SORTKEY function returns a binary value that can be used when sorting DECFLOAT values. The sorting occurs in a manner that is
  • 116. List of Scalar Functions • DECIMAL or DEC The DECIMAL function returns a decimal representation of either a number or a character-string or graphic-string representation of a number, an integer, or a decimal number. • DECODE The DECODE function compares each expression2 to expression1. If expression1 is equal to expression2, or both
  • 117. List of Scalar Functions • DECRYPT_BINARY, DECRYPT_BIT, DECRYPT_CHAR, and DECRYPT_DB The decryption functions return a value that is the result of decrypting encrypted data. The decryption functions can decrypt only values that are encrypted by using the ENCRYPT_TDES function. • DEGREES The DEGREES function returns the number of degrees of the argument, which
  • 118. List of Scalar Functions • DIFFERENCE The DIFFERENCE function returns a value, from 0 to 4, that represents the difference between the sounds of two strings, based on applying the SOUNDEX function to the strings. A value of 4 is the best possible sound match. • DIGITS The DIGITS function returns a character string representation of the absolute value
  • 119. List of Scalar Functions • DOUBLE_PRECISION or DOUBLE The DOUBLE_PRECISION and DOUBLE functions returns a floating-point representation of either a number or a character-string or graphic-string representation of a number, an integer, a decimal number, or a floating-point number. • DSN_XMLVALIDATE The DSN_XMLVALIDATE function returns
  • 120. List of Scalar Functions • EBCDIC_CHR The EBCDIC_CHR function returns the character that has the EBCDIC code value that is specified by the argument. • EBCDIC_STR The EBCDIC_STR function returns a string, in the system EBCDIC CCSID, that is an EBCDIC version of the string.
  • 121. List of Scalar Functions • ENCRYPT_TDES The ENCRYPT_TDES function returns a value that is the result of encrypting the first argument by using the Triple DES encryption algorithm. The function can also set the password that is used for encryption. • EXP The EXP function returns a value that is the base of the natural logarithm (e),
  • 122. List of Scalar Functions • EXTRACT The EXTRACT function returns a portion of a date or timestamp, based on its arguments. • FLOAT The FLOAT function returns a floating- point representation of either a number or a string representation of a number. FLOAT is a synonym for the DOUBLE function.
  • 123. List of Scalar Functions • FLOOR The FLOOR function returns the largest integer value that is less than or equal to the argument. • GENERATE_UNIQUE The GENERATE_UNIQUE function returns a bit data character string that is unique, compared to any other execution of the same function.
  • 124. List of Scalar Functions • GETHINT The GETHINT function returns a hint for the password if a hint was embedded in the encrypted data. A password hint is a phrase that helps you remember the password with which the data was encrypted. For example, 'Ocean' might be used as a hint to help remember the password 'Pacific'. • GETVARIABLE
  • 125. List of Scalar Functions • GRAPHIC The GRAPHIC function returns a fixed- length graphic-string representation of a character string or a graphic string value, depending on the type of the first argument. • HEX The HEX function returns a hexadecimal representation of a value.
  • 126. List of Scalar Functions • HOUR The HOUR function returns the hour part of a value. • IDENTITY_VAL_LOCAL The IDENTITY_VAL_LOCAL function returns the most recently assigned value for an identity column.
  • 127. List of Scalar Functions • IFNULL The IFNULL function returns the first nonnull expression. • INSERT The INSERT function returns a string where, beginning at start in source-string, length characters have been deleted and insert-string has been inserted.
  • 128. List of Scalar Functions • INTEGER or INT The INTEGER function returns an integer representation of either a number or a character string or graphic string representation of an integer. • JULIAN_DAY The JULIAN_DAY function returns an integer value that represents a number of days from January 1, 4713 B.C. (the start of the Julian date calendar) to the date
  • 129. List of Scalar Functions • LAST_DAY The LAST_DAY scalar function returns a date that represents the last day of the month of the date argument. • LCASE The LCASE function returns a string in which all the characters are converted to lowercase characters.
  • 130. List of Scalar Functions • LEFT The LEFT function returns a string that consists of the specified number of leftmost bytes of the specified string units. • LENGTH The LENGTH function returns the length of a value.
  • 131. List of Scalar Functions • LN The LN function returns the natural logarithm of the argument. The LN and EXP functions are inverse operations. • LOCATE The LOCATE function returns the position at which the first occurrence of an argument starts within another argument.
  • 132. List of Scalar Functions • LOCATE_IN_STRING The LOCATE_IN_STRING function returns the position at which an argument starts within a specified string. • LOG10 The LOG10 function returns the common logarithm (base 10) of a number.
  • 133. List of Scalar Functions • LOWER The LOWER function returns a string in which all the characters are converted to lowercase characters. • LPAD The LPAD function returns a string that is composed of string-expression that is padded on the left, with pad or blanks. The LPAD function treats leading or trailing blanks in string-expression as significant.
  • 134. List of Scalar Functions • LTRIM The LTRIM function removes bytes from the beginning of a string expression based on the content of a trim expression. • MAX The MAX scalar function returns the maximum value in a set of values.
  • 135. List of Scalar Functions • MICROSECOND The MICROSECOND function returns the microsecond part of a value. • MIDNIGHT_SECONDS The MIDNIGHT_SECONDS function returns an integer, in the range of 0 to 86400, that represents the number of seconds between midnight and the time that is specified in the argument.
  • 136. List of Scalar Functions • MIN The MIN scalar function returns the minimum value in a set of values. • MINUTE The MINUTE function returns the minute part of a value.
  • 137. List of Scalar Functions • MOD The MOD function divides the first argument by the second argument and returns the remainder. • MONTH The MONTH function returns the month part of a value.
  • 138. List of Scalar Functions • MONTHS_BETWEEN The MONTHS_BETWEEN function returns an estimate of the number of months between two arguments. • MQREAD The MQREAD function returns a message from a specified MQSeries® location without removing the message from the queue.
  • 139. List of Scalar Functions • MQREADCLOB The MQREADCLOB function returns a message from a specified MQSeries location without removing the message from the queue. • MQRECEIVE The MQRECEIVE function returns a message from a specified MQSeries location and removes the message from the queue.
  • 140. List of Scalar Functions • MQRECEIVECLOB The MQRECEIVECLOB function returns a message from a specified MQSeries location and removes the message from the queue. • MQSEND The MQSEND function sends data to a specified MQSeries location, and returns a varying-length character string that indicates whether the function was
  • 141. List of Scalar Functions • MULTIPLY_ALT The MULTIPLY_ALT scalar function returns the product of the two arguments. This function is an alternative to the multiplication operator and is especially useful when the sum of the precisions of the arguments exceeds 31. • NEXT_DAY The NEXT_DAY function returns a datetime value that represents the first
  • 142. List of Scalar Functions • NORMALIZE_DECFLOAT The NORMALIZE_DECFLOAT function returns a DECFLOAT value that is the result of the argument, set to its simplest form. That is, a non-zero number that has any trailing zeros in the coefficient has those zeros removed by dividing the coefficient by the appropriate power of ten and adjusting the exponent accordingly. A zero has its exponent set to 0.
  • 143. List of Scalar Functions • NORMALIZE_STRING The NORMALIZE_STRING function takes a Unicode string argument and returns a normalized string that can be used for comparison. • NULLIF The NULLIF function returns the null value if the two arguments are equal; otherwise, it returns the value of the first argument.
  • 144. List of Scalar Functions • NVL The NVL function returns the first argument that is not null. • OVERLAY The OVERLAY function returns a string that is composed of one argument that is inserted into another argument at the same position where some number of bytes have been deleted.
  • 145. List of Scalar Functions • PACK The PACK function returns a binary string value that contains a data type array and a packed representation of each non-null expression argument. • POSITION The POSITION function returns the position of the first occurrence of an argument within another argument, where the position is expressed in terms of the
  • 146. List of Scalar Functions • POSSTR The POSSTR function returns the position of the first occurrence of an argument within another argument. • POWER The POWER® function returns the value of the first argument to the power of the second argument.
  • 147. List of Scalar Functions • QUANTIZE The QUANTIZE function returns a DECFLOAT value that is equal in value (except for any rounding) and sign to the first argument and that has an exponent that is set to equal the exponent of the second argument. • QUARTER The QUARTER function returns an integer between 1 and 4 that represents the
  • 148. List of Scalar Functions • RADIANS The RADIANS function returns the number of radians for an argument that is expressed in degrees. • RAISE_ERROR The RAISE_ERROR function causes the statement that invokes the function to return an error with the specified SQLSTATE (along with SQLCODE -438) and error condition. The RAISE_ERROR
  • 149. List of Scalar Functions • RAND The RAND function returns a random floating-point value between 0 and 1. An argument can be specified as an optional seed value. • REAL The REAL function returns a single- precision floating-point representation of either a number or a string representation of a number.
  • 150. List of Scalar Functions • REPEAT The REPEAT function returns a character string that is composed of an argument that is repeated a specified number of times. • REPLACE The REPLACE function replaces all occurrences of search-string in source- string with replace-string. If search-string is not found in source-string, source-string
  • 151. List of Scalar Functions • RID The RID function returns the record ID (RID) of a row. The RID is used to uniquely identify a row. • RIGHT The RIGHT function returns a string that consists of the specified number of rightmost bytes or specified string unit from a string.
  • 152. List of Scalar Functions • ROUND The ROUND function returns a number that is rounded to the specified number of places to the right or left of the decimal place. • ROUND_TIMESTAMP The ROUND_TIMESTAMP scalar function returns a timestamp that is rounded to the unit that is specified by the timestamp format string.
  • 153. List of Scalar Functions • ROWID The ROWID function returns a row ID representation of its argument. • RPAD The RPAD function returns a string that is padded on the right with blanks or a specified string.
  • 154. List of Scalar Functions • RTRIM The RTRIM function removes bytes from the end of a string expression based on the content of a trim expression. • SCORE The SCORE function searches a text search index using criteria that are specified in a search argument and returns a relevance score that measures how well a document matches the query.
  • 155. List of Scalar Functions • SECOND The SECOND function returns the seconds part of a value with optional fractional seconds. • SIGN The SIGN function returns an indicator of the sign of the argument.
  • 156. List of Scalar Functions • SIN The SIN function returns the sine of the argument, where the argument is an angle, expressed in radians. • SINH The SINH function returns the hyperbolic sine of the argument, where the argument is an angle, expressed in radians.
  • 157. List of Scalar Functions • SMALLINT The SMALLINT function returns a small integer representation either of a number or of a string representation of a number. • SOUNDEX The SOUNDEX function returns a 4- character code that represents the sound of the words in the argument. The result can be compared to the results of the SOUNDEX function of other strings.
  • 158. List of Scalar Functions • SOAPHTTPC and SOAPHTTPV The SOAPHTTPC function returns a CLOB representation of XML data that results from a SOAP request to the web service that is specified by the first argument. The SOAPHTTPV function returns a VARCHAR representation of XML data that results from a SOAP request to the web service that is specified by the first argument.
  • 159. List of Scalar Functions • SOAPHTTPNC and SOAPHTTPNV The SOAPHTTPNC and SOAPHTTPNV functions allow you to specify a complete SOAP message as input and to return complete SOAP messages from the specified web service. The returned SOAP messages are CLOB or VARCHAR representations of the returned XML data.
  • 160. List of Scalar Functions • SPACE The SPACE function returns a character string that consists of the number of SBCS blanks that the argument specifies. • SQRT The SQRT function returns the square root of the argument.
  • 161. List of Scalar Functions • STRIP The STRIP function removes blanks or another specified character from the end, the beginning, or both ends of a string expression. • SUBSTR The SUBSTR function returns a substring of a string.
  • 162. List of Scalar Functions • SUBSTRING The SUBSTRING function returns a substring of a string. • TAN The TAN function returns the tangent of the argument, where the argument is an angle, expressed in radians.
  • 163. List of Scalar Functions • TANH The TANH function returns the hyperbolic tangent of the argument, where the argument is an angle, expressed in radians. • TIME The TIME function returns a time that is derived from a value.
  • 164. List of Scalar Functions • TIMESTAMP The TIMESTAMP function returns a TIMESTAMP WITHOUT TIME ZONE value from its argument or arguments. • TIMESTAMPADD The TIMESTAMPADD function returns the result of adding the specified number of the designated interval to the timestamp value.
  • 165. List of Scalar Functions • TIMESTAMP_FORMAT The TIMESTAMP_FORMAT function returns a TIMESTAMP WITHOUT TIME ZONE value that is based on the interpretation of the input string using the specified format. • TIMESTAMP_ISO The TIMESTAMP_ISO function returns a timestamp value that is based on a date, a time, or a timestamp argument.
  • 166. List of Scalar Functions • TIMESTAMPDIFF The TIMESTAMPDIFF function returns an estimated number of intervals of the type that is defined by the first argument, based on the difference between two timestamps. • TIMESTAMP_TZ The TIMESTAMP_TZ function returns a TIMESTAMP WITH TIME ZONE value from the input arguments.
  • 167. List of Scalar Functions • TO_CHAR The TO_CHAR function returns a character string representation of a timestamp value that has been formatted using a specified character template. • TO_DATE The TO_DATE function returns a timestamp value that is based on the interpretation of the input string using the specified format.
  • 168. List of Scalar Functions • TO_NUMBER The TO_NUMBER function returns a DECFLOAT(34) value that is based on the interpretation of the input string using the specified format. • TOTALORDER The TOTALORDER function returns an ordering for DECFLOAT values. The TOTALORDER function returns a small integer value that indicates how
  • 169. List of Scalar Functions • TRANSLATE The TRANSLATE function returns a value in which one or more characters of the first argument might have been converted to other characters. • TRIM The TRIM function removes bytes from the beginning, from the end, or from both the beginning and end of a string expression.
  • 170. List of Scalar Functions • TRUNCATE or TRUNC The TRUNCATE function returns the first argument, truncated as specified. Truncation is to the number of places to the right or left of the decimal point this is specified by the second argument. • TRUNC_TIMESTAMP The TRUNC_TIMESTAMP function returns a TIMESTAMP WITHOUT TIME ZONE value that is the expression,
  • 171. List of Scalar Functions • UCASE The UCASE function returns a string in which all the characters have been converted to uppercase characters. The UCASE function is identical to the UPPER function. • UNICODE The UNICODE function returns the Unicode UTF-16 code value of the leftmost character of the argument as an
  • 172. List of Scalar Functions • UNICODE_STR The UNICODE_STR function returns a string in Unicode UTF-8 or UTF-16, depending on the specified option. The string represents a Unicode encoding of the input string. • UPPER The UPPER function returns a string in which all the characters have been converted to uppercase characters.
  • 173. List of Scalar Functions • VALUE The VALUE function returns the value of the first non-null expression. • VARBINARY The VARBINARY function returns a VARBINARY (varying-length binary string) representation of a string of any type.
  • 174. List of Scalar Functions • VARCHAR The VARCHAR function returns a varying- length character string representation of the value specified by the first argument. The first argument can be a character string, a graphic string, a datetime value, an integer number, a decimal number, a floating-point number, or a row ID value.
  • 175. List of Scalar Functions • VARCHAR_FORMAT The VARCHAR_FORMAT function returns a character string representation of the first argument in the format indicated by format-string.
  • 176. List of Scalar Functions • VARGRAPHIC The VARGRAPHIC function returns a varying-length graphic string representation of a the first argument. The first argument can be a character string value or a graphic string value. • VERIFY_GROUP_FOR_USER The VERIFY_GROUP_FOR_USER function returns a value that indicates whether the primary authorization ID and
  • 177. List of Scalar Functions • VERIFY_ROLE_FOR_USER The VERIFY_ROLE_FOR_USER function returns a value that indicates whether the roles that are associated with the authorization ID that is specified in the first argument are included in the role names that are specified in the list of the second argument.
  • 178. List of Scalar Functions • VERIFY_TRUSTED_CONTEXT_ROLE_F OR_USER The VERIFY_TRUSTED_CONTEXT_FOR_US ER function returns a value that indicates whether the authorization ID that is associated with first argument has acquired a role in a trusted connection and whether that acquired role is included in the role names that are specified in the list
  • 179. List of Scalar Functions • WEEK The WEEK function returns an integer in the range of 1 to 54 that represents the week of the year. The week starts with Sunday, and January 1 is always in the first week. • WEEK_ISO The WEEK_ISO function returns an integer in the range of 1 to 53 that represents the week of the year. The week
  • 180. List of Scalar Functions • XMLATTRIBUTES The XMLATTRIBUTES function constructs XML attributes from the arguments. This function can be used as an argument only for the XMLELEMENT function. • XMLCOMMENT The XMLCOMMENT function returns an XML value with a single comment node from a string expression. The content of the comment node is the value of the input
  • 181. List of Scalar Functions • XMLCONCAT The XMLCONCAT function returns an XML sequence that contains the concatenation of a variable number of XML input arguments. • XMLDOCUMENT The XMLDOCUMENT function returns an XML value with a single document node and zero or more nodes as its children. The content of the generated XML
  • 182. List of Scalar Functions • XMLELEMENT The XMLELEMENT function returns an XML value that is an XML element node. • XMLFOREST The XMLFOREST function returns an XML value that is a sequence of XML element nodes. • XMLMODIFY The XMLMODIFY function returns an XML value that might have been modified by
  • 183. List of Scalar Functions • XMLNAMESPACES The XMLNAMESPACES function constructs namespace declarations from the arguments. This function can be used as an argument only for specific functions, such as the XMLELEMENT function and the XMLFOREST function. • XMLPARSE The XMLPARSE function parses the argument as an XML document and
  • 184. List of Scalar Functions • XMLPI The XMLPI function returns an XML value with a single processing instruction node. • XMLQUERY The XMLQUERY function returns an XML value from the evaluation of an XQuery expression, by using specified input arguments, a context item, and XQuery variables.
  • 185. List of Scalar Functions • XMLSERIALIZE The XMLSERIALIZE function returns a serialized XML value of the specified data type that is generated from the first argument. • XMLTEXT The XMLTEXT function returns an XML value with a single text node that contains the value of the argument.
  • 186. List of Scalar Functions • XMLXSROBJECTID The XMLXSROBJECTID function returns the XSR object identifier of the XML schema that is used to validate the XML document specified in the argument. • XSLTRANSFORM The XSLTRANSFORM function transforms an XML document into a different data format. The output can be any form possible for the XSLT processor,
  • 187. List of Scalar Functions • YEAR The YEAR function returns the year part of a value that is a character or graphic string. The value must be a valid string representation of a date or timestamp.