SlideShare a Scribd company logo
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

PDF
Introduction to oracle functions
PPTX
Aggregate function
PPT
05 Creating Stored Procedures
PPTX
STRUCTURE OF SQL QUERIES
PPT
SQL subquery
PPT
Aggregating Data Using Group Functions
PPTX
SQL Queries Information
Introduction to oracle functions
Aggregate function
05 Creating Stored Procedures
STRUCTURE OF SQL QUERIES
SQL subquery
Aggregating Data Using Group Functions
SQL Queries Information

What's hot (20)

PPT
SQL Tutorial - Basic Commands
PPT
PPT
Displaying Data from Multiple Tables - Oracle Data Base
PPT
Single-Row Functions in orcale Data base
PPTX
PLSQL Tutorial
ODP
Ms sql-server
PPT
Using the set operators
PPT
Subqueries -Oracle DataBase
DOC
80 different SQL Queries with output
DOC
SQL practice questions - set 3
DOC
SQL practice questions set - 2
PPTX
T4 - Query Lanjutan [2]
PPTX
Packages in PL/SQL
PPTX
SQL Server Learning Drive
PPTX
Sql queries presentation
PPTX
MYSQL join
PPTX
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
PPTX
Basic SQL and History
DOCX
Top 40 sql queries for testers
PPT
Including Constraints -Oracle Data base
SQL Tutorial - Basic Commands
Displaying Data from Multiple Tables - Oracle Data Base
Single-Row Functions in orcale Data base
PLSQL Tutorial
Ms sql-server
Using the set operators
Subqueries -Oracle DataBase
80 different SQL Queries with output
SQL practice questions - set 3
SQL practice questions set - 2
T4 - Query Lanjutan [2]
Packages in PL/SQL
SQL Server Learning Drive
Sql queries presentation
MYSQL join
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
Basic SQL and History
Top 40 sql queries for testers
Including Constraints -Oracle Data base
Ad

Similar to Oracle: Functions (20)

PPT
Single row functions
PPT
Oracle tips and tricks
PPT
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
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
Ad

More from oracle content (13)

PPTX
Oracle: Procedures
PPTX
Oracle: PLSQL Introduction
PPTX
Oracle : DML
PPTX
Oracle: Programs
PPTX
Oracle: Commands
PPTX
Oracle: Joins
PPTX
Oracle:Cursors
PPTX
Oracle: Control Structures
PPTX
Oracle: Dw Design
PPTX
Oracle: Basic SQL
PPTX
Oracle Warehouse
PPT
Oracle: New Plsql
PPTX
Oracle: Fundamental Of Dw
Oracle: Procedures
Oracle: PLSQL Introduction
Oracle : DML
Oracle: Programs
Oracle: Commands
Oracle: Joins
Oracle:Cursors
Oracle: Control Structures
Oracle: Dw Design
Oracle: Basic SQL
Oracle Warehouse
Oracle: New Plsql
Oracle: Fundamental Of Dw

Recently uploaded (20)

PDF
cuic standard and advanced reporting.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Tartificialntelligence_presentation.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Getting Started with Data Integration: FME Form 101
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
cuic standard and advanced reporting.pdf
Electronic commerce courselecture one. Pdf
MIND Revenue Release Quarter 2 2025 Press Release
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
20250228 LYD VKU AI Blended-Learning.pptx
Tartificialntelligence_presentation.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Digital-Transformation-Roadmap-for-Companies.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Diabetes mellitus diagnosis method based random forest with bat algorithm
MYSQL Presentation for SQL database connectivity
Encapsulation_ Review paper, used for researhc scholars
A comparative analysis of optical character recognition models for extracting...
Per capita expenditure prediction using model stacking based on satellite ima...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Getting Started with Data Integration: FME Form 101
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Building Integrated photovoltaic BIPV_UPV.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf

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