SlideShare a Scribd company logo
3
Most read
4
Most read
1Using ORACLE®Using functions(single row and aggregate functions)And the ‘GROUP BY ‘ clause
2FUNCTIONSWe have many functions in Oracle that can be used to perform a myriad of tasks.There are two types of functions viz:Functions take input ,process it and provide the output.Single row functions operate only on one row (1 input and 1 output)Aggregate functions can operate on a range of rows  ( multiple inputs and one output)
3FUNCTIONSSingle row functions can be divided into different parts as:CharacterSingle row functionsNumberGeneralConversionDate
4CHARACTER FUNCTIONSCase manipulation functionsCharacter manipulation functions
5CHARACTER FUNCTIONSSELECTprod_ID, INITCAP  (prod_name) , CONCAT ('Rs ',prod_cost) AS COST FROM  product_masterWHERE prod_name LIKE(  LOWER  ('TEAK%'));SELECTprod_ID, UPPER   (prod_name) , CONCAT  ('Rs ',prod_cost) AS COST FROM  product_masterWHERE prod_name LIKE (  CONCAT  ( '%',  SUBSTR  ( 'teak_sofa', 6, 4  )));Equivalent to LIKE ( ‘%sofa’);
6NUMBER FUNCTIONSSELECT ROUND   (3.14126,4), TRUNC   (3.14126,4) , MOD    ( 22, 7 ) FROM DUAL     ;(DUAL is a dummy table in Oracle used to perform calculations.)SELECTprod_ID , prod_name , ROUND(  MOD       (prod_stock,prod_order),0)                            AS REORDER_LVLFROM product_masterORDER BY REORDER_LVL;(Here we use the alias name to order the output)
7DATE FUNCTIONSWe can use either MONTH or YEAR as parameters in the ROUND and TRUNC functions.
8DATE MANIPULATIONSApart from the date functions we can also perform arithmetic operations on dates as:.Adding or subtracting a number to or from a date to get a resultant date.Subtracting two dates to find the number of days between those dates.Adding hours to a date by dividing the number of hours by 24.SELECT   SYSDATEASTODAY,			(SYSDATE+1) AS NEXT_DAY,			(SYSDATE-1) AS PREV_DAYFROM DUAL;
9CONVERSION FUNCTIONSHere in the TO_NUMBER function we are converting the string ‘2000’ to a number 2000.In TO_DATE we have to specify the format of the output date and In TO_CHAR we have to specify the format of input date to be converted to a string
10GENERAL FUNCTIONSSELECT prod_ID, prod_name, NVL       (prod_order,0),  NVL2   (prod_sales,'YES','NO'), NULLIF  	(prod_stock,(prod_order+prod_sales))  AS NULLIFFROM product_master;
11AGGREGATE FUNCTIONSAggregate functions take multiple rows as input and give one output. The SYNTAX is:SELECT  column1,column2…….aggregate_function( column)…FROMtable_nameWHERE (expression/condition);
12AGGREGATE FUNCTIONSSELECT   COUNT  (prod_ID) AS COUNT,  MIN  (prod_cost) AS MINIMUM,  MAX  (prod_sales) AS MAXIMUM,   AVG   (prod_cost) AS AVERAGE,  SUM  (prod_stock) AS SUM, ROUND( STDDEV   (prod_sales),3) AS STD_DEVIAYION,ROUND(  VARIANCE   (prod_stock),3) AS VARIANCEFROM product_master;(We can also use ‘*’ in COUNT and ‘DISTINCT’ in AVG )
13GROUP BY CLAUSEWhen we wish to divide the table into multiple groups based on some criterion we use the ‘GROUP BY’ clause.It is mandatory that while using a group by clause we include the column used in the group must not be used in a aggregate function in the SELECT statement.SYNTAX:SELECT  column1,column2…….aggregate_function( column)…FROMtable_nameGROUP BY columnWHERE (expression/condition);It is mandatory to use the group by clause when displaying  any column along with a aggregratefunction.We can also use multiple columns in the group by clause.Use the WHERE clause to furthur filter results.
THANK YOU14THANK YOU FOR VIEWING THIS PRESENTATIONFOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING ,please visit:  www.dataminingtools.net

More Related Content

PPTX
Oracle SQL Functions
PPT
Aggregate Functions,Final
PPTX
Structured query language functions
PPTX
Oracle: PLSQL Introduction
PPTX
Structured query language constraints
PPTX
Oracle: DML
PPT
DOCX
Inventory aging report using oracle discoverer desktop
Oracle SQL Functions
Aggregate Functions,Final
Structured query language functions
Oracle: PLSQL Introduction
Structured query language constraints
Oracle: DML
Inventory aging report using oracle discoverer desktop

What's hot (19)

PPT
PPT
PDF
SQL Functions and Operators
PDF
Data Definition Language (DDL)
PDF
Sq lite functions
PDF
Sql queries
ODP
My sql Syntax
ODP
Prabu's sql quries
PPTX
Oracle: PLSQL Commands
PPTX
Oracle: DDL
PDF
Mysql clone-tables
DOC
30 08 Final Sql
PPTX
MYSQL single rowfunc-multirowfunc-groupby-having
PPTX
Lab3 aggregating data
PPT
Les07[1]Multiple-Column Subqueries
PDF
Alter table command
PDF
Data Preparation- handling missing value
PDF
Mysql alter-command
ODP
Babitha2.mysql
SQL Functions and Operators
Data Definition Language (DDL)
Sq lite functions
Sql queries
My sql Syntax
Prabu's sql quries
Oracle: PLSQL Commands
Oracle: DDL
Mysql clone-tables
30 08 Final Sql
MYSQL single rowfunc-multirowfunc-groupby-having
Lab3 aggregating data
Les07[1]Multiple-Column Subqueries
Alter table command
Data Preparation- handling missing value
Mysql alter-command
Babitha2.mysql
Ad

Viewers also liked (20)

PPT
Sample file processing
PPT
PPT
e computer notes - Single row functions
PPT
Single-Row Functions in orcale Data base
PDF
Oracle sql in 7 days by suesh.n v 1.0
PDF
Keynote Presentation
PDF
File Processing System
PPTX
XL-MINER:Prediction
PPTX
LISP:Predicates in lisp
PPTX
DataKraft - Powerful No-Coding Platform for Business Applications
PPTX
Data Applied:Forecast
PPTX
Data Applied:Tree Maps
PDF
Cinnamonhotel saigon 2013_01
PPT
Excel Datamining Addin Intermediate
PPTX
LISP: Scope and extent in lisp
PPTX
LISP: Errors In Lisp
PPT
Wisconsin Fertility Institute: Injection Class 2011
PPTX
Data Applied:Decision Trees
ODP
Presentazione oroblu
PPTX
Quick Look At Clustering
Sample file processing
e computer notes - Single row functions
Single-Row Functions in orcale Data base
Oracle sql in 7 days by suesh.n v 1.0
Keynote Presentation
File Processing System
XL-MINER:Prediction
LISP:Predicates in lisp
DataKraft - Powerful No-Coding Platform for Business Applications
Data Applied:Forecast
Data Applied:Tree Maps
Cinnamonhotel saigon 2013_01
Excel Datamining Addin Intermediate
LISP: Scope and extent in lisp
LISP: Errors In Lisp
Wisconsin Fertility Institute: Injection Class 2011
Data Applied:Decision Trees
Presentazione oroblu
Quick Look At Clustering
Ad

Similar to Oracle: Functions (20)

PPT
Single row functions
PPT
Oracle tips and tricks
PPT
Day1Structured_Query_Lang3For PL SQL Notes.ppt
PDF
Understand when to use user defined functions in sql server tech-republic
PPTX
Web Developer make the most out of your Database !
PDF
Oracle_Analytical_function.pdf
PPT
PDF
The Ring programming language version 1.9 book - Part 93 of 210
PDF
Cubing and Metrics in SQL, oh my!
PPSX
Analytic & Windowing functions in oracle
PDF
The Ring programming language version 1.8 book - Part 90 of 202
PDF
Oracle Database Advanced Querying
PPT
PPTX
New Features of SQL Server 2016
ODP
SQL Tunning
PPTX
Simplifying SQL with CTE's and windowing functions
PDF
The Ring programming language version 1.10 book - Part 97 of 212
PPT
ODP
PPT
Les03 (Using Single Row Functions To Customize Output)
Single row functions
Oracle tips and tricks
Day1Structured_Query_Lang3For PL SQL Notes.ppt
Understand when to use user defined functions in sql server tech-republic
Web Developer make the most out of your Database !
Oracle_Analytical_function.pdf
The Ring programming language version 1.9 book - Part 93 of 210
Cubing and Metrics in SQL, oh my!
Analytic & Windowing functions in oracle
The Ring programming language version 1.8 book - Part 90 of 202
Oracle Database Advanced Querying
New Features of SQL Server 2016
SQL Tunning
Simplifying SQL with CTE's and windowing functions
The Ring programming language version 1.10 book - Part 97 of 212
Les03 (Using Single Row Functions To Customize Output)

More from DataminingTools Inc (20)

PPTX
Terminology Machine Learning
PPTX
Techniques Machine Learning
PPTX
Machine learning Introduction
PPTX
Areas of machine leanring
PPTX
AI: Planning and AI
PPTX
AI: Logic in AI 2
PPTX
AI: Logic in AI
PPTX
AI: Learning in AI 2
PPTX
AI: Learning in AI
PPTX
AI: Introduction to artificial intelligence
PPTX
AI: Belief Networks
PPTX
AI: AI & Searching
PPTX
AI: AI & Problem Solving
PPTX
Data Mining: Text and web mining
PPTX
Data Mining: Outlier analysis
PPTX
Data Mining: Mining stream time series and sequence data
PPTX
Data Mining: Mining ,associations, and correlations
PPTX
Data Mining: Graph mining and social network analysis
PPTX
Data warehouse and olap technology
PPTX
Data Mining: Data processing
Terminology Machine Learning
Techniques Machine Learning
Machine learning Introduction
Areas of machine leanring
AI: Planning and AI
AI: Logic in AI 2
AI: Logic in AI
AI: Learning in AI 2
AI: Learning in AI
AI: Introduction to artificial intelligence
AI: Belief Networks
AI: AI & Searching
AI: AI & Problem Solving
Data Mining: Text and web mining
Data Mining: Outlier analysis
Data Mining: Mining stream time series and sequence data
Data Mining: Mining ,associations, and correlations
Data Mining: Graph mining and social network analysis
Data warehouse and olap technology
Data Mining: Data processing

Recently uploaded (20)

PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Encapsulation theory and applications.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Approach and Philosophy of On baking technology
PPTX
A Presentation on Artificial Intelligence
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Empathic Computing: Creating Shared Understanding
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
The AUB Centre for AI in Media Proposal.docx
Chapter 3 Spatial Domain Image Processing.pdf
Encapsulation theory and applications.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
NewMind AI Monthly Chronicles - July 2025
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Building Integrated photovoltaic BIPV_UPV.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
NewMind AI Weekly Chronicles - August'25 Week I
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Approach and Philosophy of On baking technology
A Presentation on Artificial Intelligence
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Machine learning based COVID-19 study performance prediction
Mobile App Security Testing_ A Comprehensive Guide.pdf
Empathic Computing: Creating Shared Understanding

Oracle: Functions

  • 1. 1Using ORACLE®Using functions(single row and aggregate functions)And the ‘GROUP BY ‘ clause
  • 2. 2FUNCTIONSWe have many functions in Oracle that can be used to perform a myriad of tasks.There are two types of functions viz:Functions take input ,process it and provide the output.Single row functions operate only on one row (1 input and 1 output)Aggregate functions can operate on a range of rows ( multiple inputs and one output)
  • 3. 3FUNCTIONSSingle row functions can be divided into different parts as:CharacterSingle row functionsNumberGeneralConversionDate
  • 4. 4CHARACTER FUNCTIONSCase manipulation functionsCharacter manipulation functions
  • 5. 5CHARACTER FUNCTIONSSELECTprod_ID, INITCAP (prod_name) , CONCAT ('Rs ',prod_cost) AS COST FROM product_masterWHERE prod_name LIKE( LOWER ('TEAK%'));SELECTprod_ID, UPPER (prod_name) , CONCAT ('Rs ',prod_cost) AS COST FROM product_masterWHERE prod_name LIKE ( CONCAT ( '%', SUBSTR ( 'teak_sofa', 6, 4 )));Equivalent to LIKE ( ‘%sofa’);
  • 6. 6NUMBER FUNCTIONSSELECT ROUND (3.14126,4), TRUNC (3.14126,4) , MOD ( 22, 7 ) FROM DUAL ;(DUAL is a dummy table in Oracle used to perform calculations.)SELECTprod_ID , prod_name , ROUND( MOD (prod_stock,prod_order),0) AS REORDER_LVLFROM product_masterORDER BY REORDER_LVL;(Here we use the alias name to order the output)
  • 7. 7DATE FUNCTIONSWe can use either MONTH or YEAR as parameters in the ROUND and TRUNC functions.
  • 8. 8DATE MANIPULATIONSApart from the date functions we can also perform arithmetic operations on dates as:.Adding or subtracting a number to or from a date to get a resultant date.Subtracting two dates to find the number of days between those dates.Adding hours to a date by dividing the number of hours by 24.SELECT SYSDATEASTODAY, (SYSDATE+1) AS NEXT_DAY, (SYSDATE-1) AS PREV_DAYFROM DUAL;
  • 9. 9CONVERSION FUNCTIONSHere in the TO_NUMBER function we are converting the string ‘2000’ to a number 2000.In TO_DATE we have to specify the format of the output date and In TO_CHAR we have to specify the format of input date to be converted to a string
  • 10. 10GENERAL FUNCTIONSSELECT prod_ID, prod_name, NVL (prod_order,0), NVL2 (prod_sales,'YES','NO'), NULLIF (prod_stock,(prod_order+prod_sales)) AS NULLIFFROM product_master;
  • 11. 11AGGREGATE FUNCTIONSAggregate functions take multiple rows as input and give one output. The SYNTAX is:SELECT column1,column2…….aggregate_function( column)…FROMtable_nameWHERE (expression/condition);
  • 12. 12AGGREGATE FUNCTIONSSELECT COUNT (prod_ID) AS COUNT, MIN (prod_cost) AS MINIMUM, MAX (prod_sales) AS MAXIMUM, AVG (prod_cost) AS AVERAGE, SUM (prod_stock) AS SUM, ROUND( STDDEV (prod_sales),3) AS STD_DEVIAYION,ROUND( VARIANCE (prod_stock),3) AS VARIANCEFROM product_master;(We can also use ‘*’ in COUNT and ‘DISTINCT’ in AVG )
  • 13. 13GROUP BY CLAUSEWhen we wish to divide the table into multiple groups based on some criterion we use the ‘GROUP BY’ clause.It is mandatory that while using a group by clause we include the column used in the group must not be used in a aggregate function in the SELECT statement.SYNTAX:SELECT column1,column2…….aggregate_function( column)…FROMtable_nameGROUP BY columnWHERE (expression/condition);It is mandatory to use the group by clause when displaying any column along with a aggregratefunction.We can also use multiple columns in the group by clause.Use the WHERE clause to furthur filter results.
  • 14. THANK YOU14THANK YOU FOR VIEWING THIS PRESENTATIONFOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING ,please visit: www.dataminingtools.net