SlideShare a Scribd company logo
1 of 14
1 Using ORACLE® Using functions (single row and aggregate functions) And the ‘GROUP BY ‘ clause
2 FUNCTIONS We 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 FUNCTIONS Single row functions can be divided into different parts as: Character Single row functions Number General Conversion Date
4 CHARACTER FUNCTIONS Case manipulation functions Character manipulation functions
5 CHARACTER FUNCTIONS SELECTprod_ID, INITCAP  (prod_name) , CONCAT ('Rs ',prod_cost) AS COST  FROM  product_master WHERE prod_name LIKE(  LOWER  ('TEAK%')); SELECTprod_ID, UPPER   (prod_name) , CONCAT  ('Rs ',prod_cost) AS COST  FROM  product_master WHERE prod_name LIKE (  CONCAT  ( '%',  SUBSTR  ( 'teak_sofa', 6, 4  ))); Equivalent to LIKE ( ‘%sofa’);
6 NUMBER FUNCTIONS SELECT 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_LVL FROM product_master ORDER BY REORDER_LVL; (Here we use the alias name to order the output)
7 DATE FUNCTIONS We can use either MONTH or YEAR as parameters in the ROUND and TRUNC functions.
8 DATE MANIPULATIONS Apart 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_DAY FROM DUAL;
9 CONVERSION FUNCTIONS Here 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 GENERAL FUNCTIONS SELECT prod_ID, prod_name, NVL       (prod_order,0),  NVL2   (prod_sales,'YES','NO'),  NULLIF  	(prod_stock,(prod_order+prod_sales))  AS NULLIF FROM product_master;
11 AGGREGATE FUNCTIONS Aggregate functions take multiple rows as input and give one output. The SYNTAX is: SELECT  column1,column2…….aggregate_function( column)… FROMtable_name WHERE (expression/condition);
12 AGGREGATE FUNCTIONS SELECT   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 VARIANCE FROM product_master; (We can also use ‘*’ in COUNT and ‘DISTINCT’ in AVG )
13 GROUP BY CLAUSE When 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_name GROUP BY column WHERE (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 YOU 14 THANK YOU FOR VIEWING THIS PRESENTATION FOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING , please visit:   www.dataminingtools.net

More Related Content

What's hot (20)

MYSQL
MYSQLMYSQL
MYSQL
 
Cursors
CursorsCursors
Cursors
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
Joins And Its Types
Joins And Its TypesJoins And Its Types
Joins And Its Types
 
SQL
SQLSQL
SQL
 
Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)
 
Sql select
Sql select Sql select
Sql select
 
Exception handling in plsql
Exception handling in plsqlException handling in plsql
Exception handling in plsql
 
MySQL Basics
MySQL BasicsMySQL Basics
MySQL Basics
 
PLSQL Tutorial
PLSQL TutorialPLSQL Tutorial
PLSQL Tutorial
 
AGGREGATE FUNCTION.pptx
AGGREGATE FUNCTION.pptxAGGREGATE FUNCTION.pptx
AGGREGATE FUNCTION.pptx
 
sql function(ppt)
sql function(ppt)sql function(ppt)
sql function(ppt)
 
Sql commands
Sql commandsSql commands
Sql commands
 
Mysql
MysqlMysql
Mysql
 
Packages in PL/SQL
Packages in PL/SQLPackages in PL/SQL
Packages in PL/SQL
 
Trigger in mysql
Trigger in mysqlTrigger in mysql
Trigger in mysql
 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIES
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
 

Similar to Oracle: Functions

Oracle tips and tricks
Oracle tips and tricksOracle tips and tricks
Oracle tips and tricksYanli Liu
 
Understand when to use user defined functions in sql server tech-republic
Understand when to use user defined functions in sql server   tech-republicUnderstand when to use user defined functions in sql server   tech-republic
Understand when to use user defined functions in sql server tech-republicKaing Menglieng
 
Web Developer make the most out of your Database !
Web Developer make the most out of your Database !Web Developer make the most out of your Database !
Web Developer make the most out of your Database !Jean-Marc Desvaux
 
Oracle_Analytical_function.pdf
Oracle_Analytical_function.pdfOracle_Analytical_function.pdf
Oracle_Analytical_function.pdfKalyankumarVenkat1
 
The Ring programming language version 1.9 book - Part 93 of 210
The Ring programming language version 1.9 book - Part 93 of 210The Ring programming language version 1.9 book - Part 93 of 210
The Ring programming language version 1.9 book - Part 93 of 210Mahmoud Samir Fayed
 
Cubing and Metrics in SQL, oh my!
Cubing and Metrics in SQL, oh my!Cubing and Metrics in SQL, oh my!
Cubing and Metrics in SQL, oh my!Julian Hyde
 
Analytic & Windowing functions in oracle
Analytic & Windowing functions in oracleAnalytic & Windowing functions in oracle
Analytic & Windowing functions in oracleLogan Palanisamy
 
The Ring programming language version 1.8 book - Part 90 of 202
The Ring programming language version 1.8 book - Part 90 of 202The Ring programming language version 1.8 book - Part 90 of 202
The Ring programming language version 1.8 book - Part 90 of 202Mahmoud Samir Fayed
 
Oracle Database Advanced Querying
Oracle Database Advanced QueryingOracle Database Advanced Querying
Oracle Database Advanced QueryingZohar Elkayam
 
New Features of SQL Server 2016
New Features of SQL Server 2016New Features of SQL Server 2016
New Features of SQL Server 2016Mir Mahmood
 
Simplifying SQL with CTE's and windowing functions
Simplifying SQL with CTE's and windowing functionsSimplifying SQL with CTE's and windowing functions
Simplifying SQL with CTE's and windowing functionsClayton Groom
 
The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212Mahmoud Samir Fayed
 
Les03 (Using Single Row Functions To Customize Output)
Les03 (Using Single Row Functions To Customize Output)Les03 (Using Single Row Functions To Customize Output)
Les03 (Using Single Row Functions To Customize Output)Achmad Solichin
 

Similar to Oracle: Functions (20)

Single row functions
Single row functionsSingle row functions
Single row functions
 
Oracle tips and tricks
Oracle tips and tricksOracle tips and tricks
Oracle tips and tricks
 
Les17
Les17Les17
Les17
 
Understand when to use user defined functions in sql server tech-republic
Understand when to use user defined functions in sql server   tech-republicUnderstand when to use user defined functions in sql server   tech-republic
Understand when to use user defined functions in sql server tech-republic
 
Web Developer make the most out of your Database !
Web Developer make the most out of your Database !Web Developer make the most out of your Database !
Web Developer make the most out of your Database !
 
Oracle_Analytical_function.pdf
Oracle_Analytical_function.pdfOracle_Analytical_function.pdf
Oracle_Analytical_function.pdf
 
Les04
Les04Les04
Les04
 
The Ring programming language version 1.9 book - Part 93 of 210
The Ring programming language version 1.9 book - Part 93 of 210The Ring programming language version 1.9 book - Part 93 of 210
The Ring programming language version 1.9 book - Part 93 of 210
 
Cubing and Metrics in SQL, oh my!
Cubing and Metrics in SQL, oh my!Cubing and Metrics in SQL, oh my!
Cubing and Metrics in SQL, oh my!
 
Analytic & Windowing functions in oracle
Analytic & Windowing functions in oracleAnalytic & Windowing functions in oracle
Analytic & Windowing functions in oracle
 
The Ring programming language version 1.8 book - Part 90 of 202
The Ring programming language version 1.8 book - Part 90 of 202The Ring programming language version 1.8 book - Part 90 of 202
The Ring programming language version 1.8 book - Part 90 of 202
 
Oracle Database Advanced Querying
Oracle Database Advanced QueryingOracle Database Advanced Querying
Oracle Database Advanced Querying
 
Les03
Les03Les03
Les03
 
New Features of SQL Server 2016
New Features of SQL Server 2016New Features of SQL Server 2016
New Features of SQL Server 2016
 
SQL Tunning
SQL TunningSQL Tunning
SQL Tunning
 
Simplifying SQL with CTE's and windowing functions
Simplifying SQL with CTE's and windowing functionsSimplifying SQL with CTE's and windowing functions
Simplifying SQL with CTE's and windowing functions
 
The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212The Ring programming language version 1.10 book - Part 97 of 212
The Ring programming language version 1.10 book - Part 97 of 212
 
Les03
Les03Les03
Les03
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
Les03 (Using Single Row Functions To Customize Output)
Les03 (Using Single Row Functions To Customize Output)Les03 (Using Single Row Functions To Customize Output)
Les03 (Using Single Row Functions To Customize Output)
 

More from oracle content

More from oracle content (13)

Oracle: Procedures
Oracle: ProceduresOracle: Procedures
Oracle: Procedures
 
Oracle: PLSQL Introduction
Oracle: PLSQL IntroductionOracle: PLSQL Introduction
Oracle: PLSQL Introduction
 
Oracle : DML
Oracle : DMLOracle : DML
Oracle : DML
 
Oracle: Programs
Oracle: ProgramsOracle: Programs
Oracle: Programs
 
Oracle: Commands
Oracle: CommandsOracle: Commands
Oracle: Commands
 
Oracle: Joins
Oracle: JoinsOracle: Joins
Oracle: Joins
 
Oracle:Cursors
Oracle:CursorsOracle:Cursors
Oracle:Cursors
 
Oracle: Control Structures
Oracle:  Control StructuresOracle:  Control Structures
Oracle: Control Structures
 
Oracle: Dw Design
Oracle: Dw DesignOracle: Dw Design
Oracle: Dw Design
 
Oracle: Basic SQL
Oracle: Basic SQLOracle: Basic SQL
Oracle: Basic SQL
 
Oracle Warehouse
Oracle WarehouseOracle Warehouse
Oracle Warehouse
 
Oracle: New Plsql
Oracle: New PlsqlOracle: New Plsql
Oracle: New Plsql
 
Oracle: Fundamental Of Dw
Oracle: Fundamental Of DwOracle: Fundamental Of Dw
Oracle: Fundamental Of Dw
 

Recently uploaded

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 

Recently uploaded (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Oracle: Functions

  • 1. 1 Using ORACLE® Using functions (single row and aggregate functions) And the ‘GROUP BY ‘ clause
  • 2. 2 FUNCTIONS We 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. 3 FUNCTIONS Single row functions can be divided into different parts as: Character Single row functions Number General Conversion Date
  • 4. 4 CHARACTER FUNCTIONS Case manipulation functions Character manipulation functions
  • 5. 5 CHARACTER FUNCTIONS SELECTprod_ID, INITCAP (prod_name) , CONCAT ('Rs ',prod_cost) AS COST FROM product_master WHERE prod_name LIKE( LOWER ('TEAK%')); SELECTprod_ID, UPPER (prod_name) , CONCAT ('Rs ',prod_cost) AS COST FROM product_master WHERE prod_name LIKE ( CONCAT ( '%', SUBSTR ( 'teak_sofa', 6, 4 ))); Equivalent to LIKE ( ‘%sofa’);
  • 6. 6 NUMBER FUNCTIONS SELECT 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_LVL FROM product_master ORDER BY REORDER_LVL; (Here we use the alias name to order the output)
  • 7. 7 DATE FUNCTIONS We can use either MONTH or YEAR as parameters in the ROUND and TRUNC functions.
  • 8. 8 DATE MANIPULATIONS Apart 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_DAY FROM DUAL;
  • 9. 9 CONVERSION FUNCTIONS Here 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. 10 GENERAL FUNCTIONS SELECT prod_ID, prod_name, NVL (prod_order,0), NVL2 (prod_sales,'YES','NO'), NULLIF (prod_stock,(prod_order+prod_sales)) AS NULLIF FROM product_master;
  • 11. 11 AGGREGATE FUNCTIONS Aggregate functions take multiple rows as input and give one output. The SYNTAX is: SELECT column1,column2…….aggregate_function( column)… FROMtable_name WHERE (expression/condition);
  • 12. 12 AGGREGATE FUNCTIONS SELECT 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 VARIANCE FROM product_master; (We can also use ‘*’ in COUNT and ‘DISTINCT’ in AVG )
  • 13. 13 GROUP BY CLAUSE When 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_name GROUP BY column WHERE (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 YOU 14 THANK YOU FOR VIEWING THIS PRESENTATION FOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING , please visit: www.dataminingtools.net