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

What's hot (19)

PPT
Les18
Vijay Kumar
 
PPT
Les10
arnold 7490
 
PDF
SQL Functions and Operators
Mohan Kumar.R
 
PDF
Data Definition Language (DDL)
Mohd Tousif
 
PDF
Sq lite functions
punu_82
 
PDF
Sql queries
Paritosh Gupta
 
ODP
My sql Syntax
Reka
 
ODP
Prabu's sql quries
Prabu Cse
 
PPTX
Oracle: PLSQL Commands
DataminingTools Inc
 
PPTX
Oracle: DDL
DataminingTools Inc
 
PDF
Mysql clone-tables
beben benzy
 
DOC
30 08 Final Sql
sarov
 
PPTX
MYSQL single rowfunc-multirowfunc-groupby-having
Ahmed Farag
 
PPTX
Lab3 aggregating data
Balqees Al.Mubarak
 
PPT
Les07[1]Multiple-Column Subqueries
siavosh kaviani
 
PDF
Alter table command
ravikhandelwal41
 
PDF
Data Preparation- handling missing value
Rupak Roy
 
PDF
Mysql alter-command
beben benzy
 
ODP
Babitha2.mysql
banubabitha
 
SQL Functions and Operators
Mohan Kumar.R
 
Data Definition Language (DDL)
Mohd Tousif
 
Sq lite functions
punu_82
 
Sql queries
Paritosh Gupta
 
My sql Syntax
Reka
 
Prabu's sql quries
Prabu Cse
 
Oracle: PLSQL Commands
DataminingTools Inc
 
Oracle: DDL
DataminingTools Inc
 
Mysql clone-tables
beben benzy
 
30 08 Final Sql
sarov
 
MYSQL single rowfunc-multirowfunc-groupby-having
Ahmed Farag
 
Lab3 aggregating data
Balqees Al.Mubarak
 
Les07[1]Multiple-Column Subqueries
siavosh kaviani
 
Alter table command
ravikhandelwal41
 
Data Preparation- handling missing value
Rupak Roy
 
Mysql alter-command
beben benzy
 
Babitha2.mysql
banubabitha
 

Viewers also liked (20)

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

Similar to Oracle: Functions (20)

PPT
Single row functions
Balqees Al.Mubarak
 
PPT
Oracle tips and tricks
Yanli Liu
 
PPT
Day1Structured_Query_Lang3For PL SQL Notes.ppt
consravs
 
PDF
Understand when to use user defined functions in sql server tech-republic
Kaing Menglieng
 
PPTX
Web Developer make the most out of your Database !
Jean-Marc Desvaux
 
PDF
Oracle_Analytical_function.pdf
KalyankumarVenkat1
 
PPT
Les04
Sudharsan S
 
PDF
The Ring programming language version 1.9 book - Part 93 of 210
Mahmoud Samir Fayed
 
PDF
Cubing and Metrics in SQL, oh my!
Julian Hyde
 
PPSX
Analytic & Windowing functions in oracle
Logan Palanisamy
 
PDF
The Ring programming language version 1.8 book - Part 90 of 202
Mahmoud Samir Fayed
 
PDF
Oracle Database Advanced Querying
Zohar Elkayam
 
PPT
Les03
Vijay Kumar
 
PPTX
New Features of SQL Server 2016
Mir Mahmood
 
ODP
SQL Tunning
Dhananjay Goel
 
PPTX
Simplifying SQL with CTE's and windowing functions
Clayton Groom
 
PDF
The Ring programming language version 1.10 book - Part 97 of 212
Mahmoud Samir Fayed
 
PPT
Les03
Sudharsan S
 
ODP
Mysqlppt
poornima sugumaran
 
PPT
Les03 (Using Single Row Functions To Customize Output)
Achmad Solichin
 
Single row functions
Balqees Al.Mubarak
 
Oracle tips and tricks
Yanli Liu
 
Day1Structured_Query_Lang3For PL SQL Notes.ppt
consravs
 
Understand when to use user defined functions in sql server tech-republic
Kaing Menglieng
 
Web Developer make the most out of your Database !
Jean-Marc Desvaux
 
Oracle_Analytical_function.pdf
KalyankumarVenkat1
 
The Ring programming language version 1.9 book - Part 93 of 210
Mahmoud Samir Fayed
 
Cubing and Metrics in SQL, oh my!
Julian Hyde
 
Analytic & Windowing functions in oracle
Logan Palanisamy
 
The Ring programming language version 1.8 book - Part 90 of 202
Mahmoud Samir Fayed
 
Oracle Database Advanced Querying
Zohar Elkayam
 
New Features of SQL Server 2016
Mir Mahmood
 
SQL Tunning
Dhananjay Goel
 
Simplifying SQL with CTE's and windowing functions
Clayton Groom
 
The Ring programming language version 1.10 book - Part 97 of 212
Mahmoud Samir Fayed
 
Les03 (Using Single Row Functions To Customize Output)
Achmad Solichin
 
Ad

More from DataminingTools Inc (20)

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

Recently uploaded (20)

PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Advancing WebDriver BiDi support in WebKit
Igalia
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Advancing WebDriver BiDi support in WebKit
Igalia
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Biography of Daniel Podor.pdf
Daniel Podor
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 

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