SlideShare a Scribd company logo
Database Management
System (LAB-05)
Md . Tanvir Khan Fahim
ID: 2014755005
Agenda
• Uses of Set Operation(Union , Intersect , Except).
• Uses of Aggregate Functions(Avg , Max , Min , Sum , Count).
• Uses of Some Other SQL Functions.
Uses of Set Operations
• The SQL operations union, intersect and except operate on relations
and corresponds to the algebra operations U, ∩ and -.
Union:
• It is used to combine the result set of two select queries.
• Eliminate duplicates.
Union All:
For duplicates, use union all clause.
Intersect:
The intersection operation between two selections returns only the common data sets or rows between them.
* Eliminate duplicates.
Intersect All:
For duplicates, use intersect all clause.
Except/Minus:
Except operations are needed to extract those tuples that are in one
SQL query but not in other query.
* Eliminate duplicates.
Uses of Set Operations
Set Operations can be demonstrated as follows:
Uses of Set Operations
Implementations of Set Operations:
Table: person Table:person1
select id from person union select id from person1;
Uses of Set Operations
select id from person union all select id from person1;
select id from person intersect select id from person1;
Uses of Set Operations
Except/Minus:
person1 person
select id from person1 minus select id from person;
Uses of Aggregate Functions
• SQL offers five built-in aggregate functions:
1. Average: avg()
2. Minimum: min()
3. Maximum: max()
4. Total: sum()
5. Count: count()
avg():The AVG() function calculates the average of a set of values.
Min(): The MIN() aggregate function returns the lowest value (minimum) in a set of non-NULL values.
Max(): The MAX() aggregate function returns the highest value (maximum) in a set of non-NULL values.
Sum(): The SUM() function returns the total sum of a numeric column.
Count(): The COUNT() function returns the number of rows in a database table.
Uses of Aggregate Functions
Implementation of Aggregate Functions:
Table: person
select avg(ID) as New_ID from person;
select min(ID) as New_ID from person;
Uses of Aggregate Functions
• select max(ID) as New_ID from person;
select sum(ID) as New_ID from person;
• select count(ID) as New_ID from person;
Uses of Some Other SQL Functions.
• There is so many functions in SQL such as:
Abs():The ABS() function returns the absolute value of a number.
select abs(-13) from dual;
Power():The POWER() function returns the value of a number raised to the power of another number.
select power(5,2) from dual;
Round(): The ROUND() function rounds a number to a specified number of decimal places.
select Round(3.75) from dual;
Uses of Some Other SQL Functions.
Sqrt(): The SQRT() function returns the square root of a number.
select sqrt(25) from dual;
Truncate(): The TRUNCATE() function truncates a number to the specified number of decimal places.
select truncate(3.1416,2) from dual;
Thank You

More Related Content

PPTX
aggregatefunction-220420051702.pptx aggregate
PPTX
AGGREGATE FUNCTION.pptx
PPTX
MS Sql Server: Doing Calculations With Functions
PPTX
MS SQLSERVER:Doing Calculations With Functions
PPTX
MS SQL SERVER: Doing Calculations With Functions
PPT
PHP mysql Aggregate functions
PPT
Advanced Sql Training
DOC
Mandatory sql functions for beginners
aggregatefunction-220420051702.pptx aggregate
AGGREGATE FUNCTION.pptx
MS Sql Server: Doing Calculations With Functions
MS SQLSERVER:Doing Calculations With Functions
MS SQL SERVER: Doing Calculations With Functions
PHP mysql Aggregate functions
Advanced Sql Training
Mandatory sql functions for beginners

Similar to database_set_operations_&_function.pptx (20)

PPT
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
PPTX
presentation on array java program operators
PPTX
ADVANCE ITT BY PRASAD
PDF
MySQL-commands.pdf
PPTX
MYSQL using set operators
PDF
Introduction to oracle functions
PPTX
BEN520 FUNDAMENTALS OF BOENGINEERING II-4 week-lecture 4.pptx
PDF
2. mathematical functions in excel
PPTX
Exploring Advanced SQL Techniques Using Analytic Functions
PPTX
Exploring Advanced SQL Techniques Using Analytic Functions
PPTX
Advance excel
PDF
MODULE 1.pdf foundations of data science for final
PDF
Oracle Advanced SQL and Analytic Functions
PDF
SQL Functions and Operators
ODP
PDF
Sql wksht-3
ODP
PPTX
Empowerment-Technology-Microsoft-Excel.pptx
PPT
MS SQL Server.ppt sql
PPT
14 operator overloading
Introduction to Oracle Functions--(SQL)--Abhishek Sharma
presentation on array java program operators
ADVANCE ITT BY PRASAD
MySQL-commands.pdf
MYSQL using set operators
Introduction to oracle functions
BEN520 FUNDAMENTALS OF BOENGINEERING II-4 week-lecture 4.pptx
2. mathematical functions in excel
Exploring Advanced SQL Techniques Using Analytic Functions
Exploring Advanced SQL Techniques Using Analytic Functions
Advance excel
MODULE 1.pdf foundations of data science for final
Oracle Advanced SQL and Analytic Functions
SQL Functions and Operators
Sql wksht-3
Empowerment-Technology-Microsoft-Excel.pptx
MS SQL Server.ppt sql
14 operator overloading
Ad

Recently uploaded (20)

PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Sustainable Sites - Green Building Construction
PDF
Digital Logic Computer Design lecture notes
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
Construction Project Organization Group 2.pptx
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
DOCX
573137875-Attendance-Management-System-original
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
Well-logging-methods_new................
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
bas. eng. economics group 4 presentation 1.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Sustainable Sites - Green Building Construction
Digital Logic Computer Design lecture notes
Internet of Things (IOT) - A guide to understanding
Arduino robotics embedded978-1-4302-3184-4.pdf
Construction Project Organization Group 2.pptx
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
OOP with Java - Java Introduction (Basics)
Embodied AI: Ushering in the Next Era of Intelligent Systems
573137875-Attendance-Management-System-original
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Lesson 3_Tessellation.pptx finite Mathematics
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Well-logging-methods_new................
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
bas. eng. economics group 4 presentation 1.pptx
Ad

database_set_operations_&_function.pptx

  • 1. Database Management System (LAB-05) Md . Tanvir Khan Fahim ID: 2014755005
  • 2. Agenda • Uses of Set Operation(Union , Intersect , Except). • Uses of Aggregate Functions(Avg , Max , Min , Sum , Count). • Uses of Some Other SQL Functions.
  • 3. Uses of Set Operations • The SQL operations union, intersect and except operate on relations and corresponds to the algebra operations U, ∩ and -. Union: • It is used to combine the result set of two select queries. • Eliminate duplicates. Union All: For duplicates, use union all clause. Intersect: The intersection operation between two selections returns only the common data sets or rows between them. * Eliminate duplicates. Intersect All: For duplicates, use intersect all clause. Except/Minus: Except operations are needed to extract those tuples that are in one SQL query but not in other query. * Eliminate duplicates.
  • 4. Uses of Set Operations Set Operations can be demonstrated as follows:
  • 5. Uses of Set Operations Implementations of Set Operations: Table: person Table:person1 select id from person union select id from person1;
  • 6. Uses of Set Operations select id from person union all select id from person1; select id from person intersect select id from person1;
  • 7. Uses of Set Operations Except/Minus: person1 person select id from person1 minus select id from person;
  • 8. Uses of Aggregate Functions • SQL offers five built-in aggregate functions: 1. Average: avg() 2. Minimum: min() 3. Maximum: max() 4. Total: sum() 5. Count: count() avg():The AVG() function calculates the average of a set of values. Min(): The MIN() aggregate function returns the lowest value (minimum) in a set of non-NULL values. Max(): The MAX() aggregate function returns the highest value (maximum) in a set of non-NULL values. Sum(): The SUM() function returns the total sum of a numeric column. Count(): The COUNT() function returns the number of rows in a database table.
  • 9. Uses of Aggregate Functions Implementation of Aggregate Functions: Table: person select avg(ID) as New_ID from person; select min(ID) as New_ID from person;
  • 10. Uses of Aggregate Functions • select max(ID) as New_ID from person; select sum(ID) as New_ID from person; • select count(ID) as New_ID from person;
  • 11. Uses of Some Other SQL Functions. • There is so many functions in SQL such as: Abs():The ABS() function returns the absolute value of a number. select abs(-13) from dual; Power():The POWER() function returns the value of a number raised to the power of another number. select power(5,2) from dual; Round(): The ROUND() function rounds a number to a specified number of decimal places. select Round(3.75) from dual;
  • 12. Uses of Some Other SQL Functions. Sqrt(): The SQRT() function returns the square root of a number. select sqrt(25) from dual; Truncate(): The TRUNCATE() function truncates a number to the specified number of decimal places. select truncate(3.1416,2) from dual;