Single-row functions in SQL allow users to manipulate data within individual rows and return a single result per row. This document describes different types of single-row functions including character, number, date, and conversion functions. It provides examples of how to use functions like UPPER, ROUND, ADD_MONTHS, TO_CHAR, and NVL to modify, format, and convert data as needed for SELECT statements. Nesting functions allows multiple operations to be performed sequentially on a data element.
SQL offers many powerful techniques for analyzing your data out of the box, but being also extendable if you are still missing something. Now much more easier in 18c with polymorphic table functions (PTF). As an evolution of table functions, PTF is invoked in the FROM clause and is capable to encapsulate the custom processing of the input data, whereas the input row type does not have to be known at design time and the output row type may first be determined by the actual PTF invocation parameters. This session will give you an introduction based on simple examples. Discover how you can develop your own flexible and self-describing extensions while focusing on business logic and leaving complex things like parallel execution to the database.
Les05[1]Aggregating Data Using Group Functionssiavosh kaviani
After completing this lesson, you should be able to do the following:
Identify the available group functions
Describe the use of group functions
Group data using the GROUP BY clause
Include or exclude grouped rows by using the HAVING clause
After completing this lesson, you should be able to do the following:
Describe various types of functions available in SQL
Use character, number, and date functions in SELECT statements
Describe the use of conversion functions
After completing this lesson, you should be able to do the following:
Describe the main database objects
Create tables
Describe the datatypes that can be used when specifying column definition
Alter table definitions
Drop, rename, and truncate tables
Recognizing patterns in a sequence of rows has been a capability that was widely desired, but not possible with SQL until now. There were many workarounds, but these were difficult to write, hard to understand, and inefficient to execute. Beginning in Oracle Database 12c, you can use the MATCH_RECOGNIZE clause to achieve this capability in native SQL that executes efficiently. This presentation discusses how to do this.
After completing this lesson, you should be able to do the following:
Describe a view
Create a view
Retrieve data through a view
Alter the definition of a view
Insert, update, and delete data through a view
Drop a view
SQL offers many powerful techniques for analyzing your data out of the box, but being also extendable if you are still missing something. Now much more easier in 18c with polymorphic table functions (PTF). As an evolution of table functions, PTF is invoked in the FROM clause and is capable to encapsulate the custom processing of the input data, whereas the input row type does not have to be known at design time and the output row type may first be determined by the actual PTF invocation parameters. This session will give you an introduction based on simple examples. Discover how you can develop your own flexible and self-describing extensions while focusing on business logic and leaving complex things like parallel execution to the database.
Les05[1]Aggregating Data Using Group Functionssiavosh kaviani
After completing this lesson, you should be able to do the following:
Identify the available group functions
Describe the use of group functions
Group data using the GROUP BY clause
Include or exclude grouped rows by using the HAVING clause
After completing this lesson, you should be able to do the following:
Describe various types of functions available in SQL
Use character, number, and date functions in SELECT statements
Describe the use of conversion functions
After completing this lesson, you should be able to do the following:
Describe the main database objects
Create tables
Describe the datatypes that can be used when specifying column definition
Alter table definitions
Drop, rename, and truncate tables
Recognizing patterns in a sequence of rows has been a capability that was widely desired, but not possible with SQL until now. There were many workarounds, but these were difficult to write, hard to understand, and inefficient to execute. Beginning in Oracle Database 12c, you can use the MATCH_RECOGNIZE clause to achieve this capability in native SQL that executes efficiently. This presentation discusses how to do this.
After completing this lesson, you should be able to do the following:
Describe a view
Create a view
Retrieve data through a view
Alter the definition of a view
Insert, update, and delete data through a view
Drop a view
Les03 Single Row Functions in Oracle and SQL.pptDrZeeshanBhatti
Functions make the basic query block more powerful and are used to manipulate data values. This is the first of two lessons that explore functions. It focuses on single-row character, number, and date functions, as well as those functions that convert data from one type to another, for example, character data to numeric data.
Single-Row Functions in orcale Data baseSalman Memon
After completing this lesson, you should be able to
do the following:
Describe various types of functions availablein SQL
Use character, number, and date functions in SELECT statements
Describe the use of conversion functions
http://phpexecutor.com
Lesson 02 - This lesson explores design issues related to overall network topology. The following sections discuss the traditional issues of bandwidth, delay, and reliability; as well as the often overlooked issues of operational simplicity and scalability, particularly as they pertain to routing.
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
2. Objectives
After completing this lesson, you should
be able to do the following:
• Describe various types of functions
available in SQL
• Use character, number, and date
functions in SELECT statements
• Describe the use of conversion
functions
3-2
3. SQL Functions
Input Output
Function
arg 1 Function
performs action
arg 2
Result
value
arg n
3-3
4. Two Types of SQL Functions
Functions
Single-row Multiple-row
functions functions
3-4
5. Single-Row Functions
• Manipulate data items
• Accept arguments and return one value
• Act on each row returned
• Return one result per row
• May modify the datatype
• Can be nested
function_name (column|expression, [arg1, arg2,...])
3-5
6. Single-Row Functions
Character
General Number
Single-row
functions
Conversion Date
3-6
7. Character Functions
Character
functions
Case conversion Character manipulation
functions functions
LOWER CONCAT
UPPER SUBSTR
INITCAP LENGTH
INSTR
LPAD
3-7
8. Case Conversion Functions
Convert case for character strings
Function Result
LOWER('SQL Course') sql course
UPPER('SQL Course') SQL COURSE
INITCAP('SQL Course') Sql Course
3-8
9. Using Case Conversion Functions
Display the employee number, name, and
department number for employee Blake.
SQL> SELECT empno, ename, deptno
2 FROM emp
3 WHERE ename = 'blake';
no rows selected
SQL> SELECT empno, ename, deptno
2 FROM emp
3 WHERE LOWER(ename) = 'blake';
EMPNO ENAME DEPTNO
--------- ---------- ---------
7698 BLAKE 30
3-9
10. Character Manipulation Functions
Manipulate character strings
Function Result
CONCAT('Good', 'String') GoodString
SUBSTR('String',1,3) Str
LENGTH('String') 6
INSTR('String', 'r') 3
LPAD(sal,10,'*') ******5000
3-10
11. Using the Character
Manipulation Functions
SQL> SELECT ename, CONCAT (ename, job), LENGTH(ename),
2 INSTR(ename, 'A')
3 FROM emp
4 WHERE SUBSTR(job,1,5) = 'SALES';
ENAME CONCAT(ENAME,JOB) LENGTH(ENAME) INSTR(ENAME,'A')
---------- ------------------- ------------- ----------------
MARTIN MARTINSALESMAN 6 2
ALLEN ALLENSALESMAN 5 1
TURNER TURNERSALESMAN 6 0
WARD WARDSALESMAN 4 2
3-11
12. Number Functions
• ROUND: Rounds value to specified
decimal
ROUND(45.926, 2) 45.93
• TRUNC: Truncates value to specified
decimal
TRUNC(45.926, 2) 45.92
• MOD: Returns remainder of division
MOD(1600, 300) 100
3-12
13. Using the ROUND Function
SQL> SELECT ROUND(45.923,2), ROUND(45.923,0),
2 ROUND(45.923,-1)
3 FROM DUAL;
ROUND(45.923,2) ROUND(45.923,0) ROUND(45.923,-1)
--------------- -------------- -----------------
45.92 46 50
3-13
14. Using the TRUNC Function
SQL> SELECT TRUNC(45.923,2), TRUNC(45.923),
2 TRUNC(45.923,-1)
3 FROM DUAL;
TRUNC(45.923,2) TRUNC(45.923) TRUNC(45.923,-1)
--------------- ------------- ---------------
45.92 45 40
3-14
15. Using the MOD Function
Calculate the remainder of the ratio of
salary to commission for all employees
whose job title is salesman.
SQL> SELECT ename, sal, comm, MOD(sal, comm)
2 FROM emp
3 WHERE job = 'SALESMAN';
ENAME SAL COMM MOD(SAL,COMM)
---------- --------- --------- -------------
MARTIN 1250 1400 1250
ALLEN 1600 300 100
TURNER 1500 0 1500
WARD 1250 500 250
3-15
16. Working with Dates
• Oracle stores dates in an internal
numeric format: century, year, month,
day, hours, minutes, seconds.
• The default date format is DD-MON-YY.
• SYSDATE is a function returning date
and time.
• DUAL is a dummy table used to view
SYSDATE.
3-16
17. Arithmetic with Dates
• Add or subtract a number to or from a
date for a resultant date value.
• Subtract two dates to find the number of
days between those dates.
• Add hours to a date by dividing the
number of hours by 24.
3-17
18. Using Arithmetic Operators
with Dates
SQL> SELECT ename, (SYSDATE-hiredate)/7 WEEKS
2 FROM emp
3 WHERE deptno = 10;
ENAME WEEKS
---------- ---------
KING 830.93709
CLARK 853.93709
MILLER 821.36566
3-18
19. Date Functions
Function Description
MONTHS_BETWEEN Number of months
between two dates
ADD_MONTHS Add calendar months to
date
NEXT_DAY Next day of the date
specified
LAST_DAY Last day of the month
ROUND Round date
TRUNC Truncate date
3-19
20. Using Date Functions
• MONTHS_BETWEEN ('01-SEP-95','11-JAN-94')
19.6774194
• ADD_MONTHS ('11-JAN-94',6) '11-JUL-94'
• NEXT_DAY ('01-SEP-95','FRIDAY') '08-SEP-95'
• LAST_DAY('01-SEP-95') '30-SEP-95'
3-20
21. Using Date Functions
• ROUND('25-JUL-95','MONTH') 01-AUG-95
• ROUND('25-JUL-95','YEAR') 01-JAN-96
• TRUNC('25-JUL-95','MONTH') 01-JUL-95
• TRUNC('25-JUL-95','YEAR') 01-JAN-95
3-21
23. Implicit Datatype Conversion
For assignments, the Oracle can
automatically convert the following:
From To
VARCHAR2 or CHAR NUMBER
VARCHAR2 or CHAR DATE
NUMBER VARCHAR2
DATE VARCHAR2
3-23
24. Implicit Datatype Conversion
For expression evaluation, the Oracle Server
can automatically convert the following:
From To
VARCHAR2 or CHAR NUMBER
VARCHAR2 or CHAR DATE
3-24
26. TO_CHAR Function with Dates
TO_CHAR(date, 'fmt')
The format model:
• Must be enclosed in single quotation marks
and is case sensitive
• Can include any valid date format element
• Has an fm element to remove padded
blanks or suppress leading zeros
• Is separated from the date value by a
comma
3-26
27. Elements of Date Format Model
YYYY Full year in numbers
YEAR Year spelled out
MM Two-digit value for month
MONTH Full name of the month
Three-letter abbreviation of the
DY
day of the week
DAY Full name of the day
3-27
28. Elements of Date Format Model
• Time elements format the time portion of
the date.
HH24:MI:SS AM 15:45:32 PM
• Add character strings by enclosing them
in double quotation marks.
DD "of" MONTH 12 of OCTOBER
• Number suffixes spell out numbers.
ddspth fourteenth
3-28
29. Using TO_CHAR Function
with Dates
SQL> SELECT ename,
2 TO_CHAR(hiredate, 'fmDD Month YYYY') HIREDATE
3 FROM emp;
ENAME HIREDATE
---------- -----------------
KING 17 November 1981
BLAKE 1 May 1981
CLARK 9 June 1981
JONES 2 April 1981
MARTIN 28 September 1981
ALLEN 20 February 1981
...
14 rows selected.
3-29
30. TO_CHAR Function with Numbers
TO_CHAR(number, 'fmt')
Use these formats with the TO_CHAR
function to display a number value as a
character:
9 Represents a number
0 Forces a zero to be displayed
$ Places a floating dollar sign
L Uses the floating local currency symbol
. Prints a decimal point
, Prints a thousand indicator
3-30
31. Using TO_CHAR Function
with Numbers
SQL> SELECT TO_CHAR(sal,'$99,999') SALARY
2 FROM emp
3 WHERE ename = 'SCOTT';
SALARY
--------
$3,000
3-31
32. TO_NUMBER and TO_DATE
Functions
• Convert a character string to a number
format using the TO_NUMBER function
TO_NUMBER(char[, 'fmt'])
• Convert a character string to a date
format using the TO_DATE function
TO_DATE(char[, 'fmt'])
3-32
33. RR Date Format
Current Year Specified Date RR Format YY Format
1995 27-OCT-95 1995 1995
1995 27-OCT-17 2017 1917
2001 27-OCT-17 2017 2017
2001 27-OCT-95 1995 2095
If the specified two-digit year is:
0–49 50–99
If two digits The return date is in The return date is in
of the 0–49 the current century the century before
current the current one
year are: The return date is in The return date is in
50–99 the century after the current century
the current one
3-33
34. NVL Function
Converts null to an actual value
• Datatypes that can be used are date,
character, and number.
• Datatypes must match
– NVL(comm,0)
– NVL(hiredate,'01-JAN-97')
– NVL(job,'No Job Yet')
3-34
35. Using the NVL Function
SQL> SELECT ename, sal, comm, (sal*12)+NVL(comm,0)
2 FROM emp;
ENAME SAL COMM (SAL*12)+NVL(COMM,0)
---------- --------- --------- --------------------
KING 5000 60000
BLAKE 2850 34200
CLARK 2450 29400
JONES 2975 35700
MARTIN 1250 1400 16400
ALLEN 1600 300 19500
...
14 rows selected.
3-35
36. DECODE Function
Facilitates conditional inquiries by doing
the work of a CASE or IF-THEN-ELSE
statement
DECODE(col/expression, search1, result1
[, search2, result2,...,]
[, default])
3-36
37. Using the DECODE Function
SQL> SELECT job, sal,
2 DECODE(job, 'ANALYST', SAL*1.1,
3 'CLERK', SAL*1.15,
4 'MANAGER', SAL*1.20,
5 SAL)
6 REVISED_SALARY
7 FROM emp;
JOB SAL REVISED_SALARY
--------- --------- --------------
PRESIDENT 5000 5000
MANAGER 2850 3420
MANAGER 2450 2940
...
14 rows selected.
3-37
38. Using the DECODE Function
Display the applicable tax rate for each
employee in department 30.
SQL> SELECT ename, sal,
2 DECODE(TRUNC(sal/1000, 0),
3 0, 0.00,
4 1, 0.09,
5 2, 0.20,
6 3, 0.30,
7 4, 0.40,
8 5, 0.42,
9 6, 0.44,
10 0.45) TAX_RATE
11 FROM emp
12 WHERE deptno = 30;
3-38
39. Nesting Functions
• Single-row functions can be nested to
any level.
• Nested functions are evaluated from
deepest level to the least-deep level.
F3(F2(F1(col,arg1),arg2),arg3)
Step 1 = Result 1
Step 2 = Result 2
Step 3 = Result 3
3-39
40. Nesting Functions
SQL> SELECT ename,
2 NVL(TO_CHAR(mgr),'No Manager')
3 FROM emp
4 WHERE mgr IS NULL;
ENAME NVL(TO_CHAR(MGR),'NOMANAGER')
---------- -----------------------------
KING No Manager
3-40
41. Summary
Use functions to do the following:
• Perform calculations on data
• Modify individual data items
• Manipulate output for groups of rows
• Alter date formats for display
• Convert column datatypes
3-41