Aggregate functions are functions that take a collection of values as input and return a single value.The ISO standard defines five (5) aggregate functions namely :-
1) COUNT
2) SUM
3) AVG
4) MIN
5) MAX
1.COUNT Function
The COUNT function returns the total number of values in the specified field. It works on both numeric and non-numeric data types. All aggregate functions by default exclude nulls values before working on the data.
MIN function
The MIN function returns the smallest value in the specified table field.
2.MAX function
Just as the name suggests, the MAX function is the opposite of the MIN function. It returns the largest value from the specified table field.
3.SUM function
Suppose we want a report that gives total amount of payments made so far. We can use the MySQL SUM function which returns the sum of all the values in the specified column. SUM works on numeric fields only. Null values are excluded from the result returned.
4.AVG function
MySQL AVG function returns the average of the values in a specified column. Just like the SUM function, it works only on numeric data types.
5.MIN function
The MIN function returns the smallest value in the specified table field.
Consists of the explanations of the basics of SQL and commands of SQL.Helpful for II PU NCERT students and also degree studeents to understand some basic things.
in this presentation the commands let you help to understand the basic of the database system software. how to retrieve data, how to feed data and manipulate it very efficiently by using this commands.
Aggregate functions are functions that take a collection of values as input and return a single value.The ISO standard defines five (5) aggregate functions namely :-
1) COUNT
2) SUM
3) AVG
4) MIN
5) MAX
1.COUNT Function
The COUNT function returns the total number of values in the specified field. It works on both numeric and non-numeric data types. All aggregate functions by default exclude nulls values before working on the data.
MIN function
The MIN function returns the smallest value in the specified table field.
2.MAX function
Just as the name suggests, the MAX function is the opposite of the MIN function. It returns the largest value from the specified table field.
3.SUM function
Suppose we want a report that gives total amount of payments made so far. We can use the MySQL SUM function which returns the sum of all the values in the specified column. SUM works on numeric fields only. Null values are excluded from the result returned.
4.AVG function
MySQL AVG function returns the average of the values in a specified column. Just like the SUM function, it works only on numeric data types.
5.MIN function
The MIN function returns the smallest value in the specified table field.
Consists of the explanations of the basics of SQL and commands of SQL.Helpful for II PU NCERT students and also degree studeents to understand some basic things.
in this presentation the commands let you help to understand the basic of the database system software. how to retrieve data, how to feed data and manipulate it very efficiently by using this commands.
This presentation gives a clear and concise description of joins in sql and several types of sql joins.
These slides also contains the pictorial representation as well as syntax for each type of joins.
Using and Creating SQL Functions with Ammar Hassan Brohi.
String Functions
Numeric Functions
String / Number Conversion Functions
Group Functions
Date and Time Functions
Date Conversion Functions
Types Of Join In Sql Server - Join With Example In Sql Serverprogrammings guru
Do you know How many types of Joins in SQL. In this ppt presentation we are discussion about types of joins in sql server eg: INNER JOIN , SELF JOIN ,OUTER JOIN ,Right outer Join,Left outer Join,Full Outer Join,CROSS JOIN .
This presentation gives a clear and concise description of joins in sql and several types of sql joins.
These slides also contains the pictorial representation as well as syntax for each type of joins.
Using and Creating SQL Functions with Ammar Hassan Brohi.
String Functions
Numeric Functions
String / Number Conversion Functions
Group Functions
Date and Time Functions
Date Conversion Functions
Types Of Join In Sql Server - Join With Example In Sql Serverprogrammings guru
Do you know How many types of Joins in SQL. In this ppt presentation we are discussion about types of joins in sql server eg: INNER JOIN , SELF JOIN ,OUTER JOIN ,Right outer Join,Left outer Join,Full Outer Join,CROSS JOIN .
Aggregating Data Using Group FunctionsSalman Memon
After completing this lesson, you should be able to
do the following:
Identify the available group functions
Describe the use of group functions
Group data using the GROUP BY clause
Include or exclude grouped rows by using the HAVING clause
http://phpexecutor.com
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docxgilpinleeanna
MSCD650 Final Exam feedback Form
MSCD650 Final Exam Grading Form
(Instructions follow the form)
Coding
55 Percent
Points Earned
Comments:
Trigger Code:
· Code meets requirements
· Code compiles cleanly
/15
Pre-Calculation Procedure Code
· Code meets requirements
· Code compiles cleanly
/15
PL/SQL Block Code
· Code meets requirements
· Code compiles cleanly
/15
Function Code
· Code meets requirements
· Code compiles cleanly
/10
/55
Unit Testing
35 Percent
Points Earned
Comments:
Unit Test for Trigger Code:
· All conditions are thoroughly tested
· The code runs successfully
· All data to prove test worked is displayed
/10
Unit Test for Procedure Code:
· All conditions are thoroughly tested
· The code runs successfully
· All data to prove test worked is displayed
· The tester can easily follow the path of the execution.
/10
.
Unit Test for PL/SQL Block Code:
· All conditions are thoroughly tested
· The code runs successfully
· All data to prove test worked is displayed
· The tester can easily follow the path of the execution.
/10
Unit Test for View/Function Code:
· All conditions are thoroughly tested
· The code runs successfully
· All data to prove test worked is displayed
· The tester can easily follow the path of the execution.
/5
/35
Documentation
10 Percent
Points Earned
Comments:
Presentation:
· The document is easy to read.
· The document is Professional in appearance
· It is easy for the reader to find what they are looking for.
/5
Documentation:
· Code is documented so that anyone who picks it up knows what it is doing.
/5
/10
Total 100
Percent
Points Earned
Comments:
Case Study
Overview of assignment
As a new ABC Consultant assigned to the XYZ Company, you have been asked to enhance the current system to include payroll processing. Although the current employee table has monthly salary and commission columns, it does not provide any means for storing employee deductions. You will add the tables necessary to store employee deductions. Next you will create a payroll pre-calculation program that will calculate the net pay for all the employees via a batch process (a stored procedure in a package, which will call other stored procedures within the package). Although this is not a complete payroll system, the unit test results must be accurate.
Next you will create two PL/SQL blocks for inserting and deleting rows from the employee deduction table. These PL/SQL blocks will be passed information from host or bind variables and a third PL/SQL block which will assign the variables defined in SQL*Plus (e.g. employee number, dollar amount and deduction name). Since the XYZ Company wants to track changes to the employee and employee deduction tables, you will create two database triggers that will update audit tables when rows are changed or deleted.
The XYZ Company also requires a view that will display specific employee information, plus the number of deductions for an employe ...
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
2. Aggregate Functions
What is an aggregate function?
An aggregate function summarizes the results
of an expression over a number of rows,
returning a single value. The general syntax for
most of the aggregate functions is as follows:
aggregate_function ([DISTINCT|ALL]
expression)
4. Examples
Consider the following Employee table:
EMPLOYEE ( EMP_ID, NAME, DEPT_NAME, SALARY)
CREATE TABLE EMPLOYEE
(
EMP_ID NUMBER,
NAME VARCHAR2(50),
DEPT_NAME VARCHAR2(50),
SALARY NUMBER
);
5. Employee Table (Contd….)
Run the following script to insert the records in the table
INSERT INTO EMPLOYEE VALUES (100,'ABC','ENG',50000);
INSERT INTO EMPLOYEE VALUES (101,'DEF','ENG',60000);
INSERT INTO EMPLOYEE VALUES (102,'GHI','PS',50000);
INSERT INTO EMPLOYEE VALUES (103,'JKL','PS',70000);
INSERT INTO EMPLOYEE VALUES (104,'MNO','SALES',75000);
INSERT INTO EMPLOYEE VALUES (105,'PQR','MKTG',70000);
INSERT INTO EMPLOYEE VALUES (106,‘STU','SALES',null);
COMMIT;
6. Select on Employee Table
After the insert when we query the Employee table we get the
following results:
Select * from Employee;
7. Performing SUM
Query 1: To find the sum of all salaries in the organization:
SELECT SUM(SALARY) FROM EMPLOYEE;
375000
Query 2: To find the sum of the salaries grouped by dept
SELECT SUM(SALARY) FROM EMPLOYEE GROUP BY
DEPT_NAME
8. SUM (Continued)
If we take a look at the previous query the information won’t
tell us what’s the sum for a particular department. So to include that
information we add DEPT_NAME in the SELECT
SELECT DEPT_NAME,SUM(SALARY) FROM EMPLOYEE
GROUP BY DEPT_NAME;
9. SUM (Continued…..)
The query in the previous slide lists the information for all the
departments. What if we want the information to be restricted only
for a particular department like Engg
Is this query correct?
SELECT DEPT_NAME,SUM(SALARY) FROM EMPLOYEE
GROUP BY
DEPT_NAME
WHERE DEPT_NAME = 'ENG';
10. SUM (Continued….)
No, the query would result in the sql error (in Oracle)
ORA-00933: SQL Command not properly ended
Remember : If we use the aggregate functions then you cannot use
the WHERE clause. In order to get the result what we need to use is
the HAVING clause. So the query would be
SELECT DEPT_NAME,SUM(SALARY) FROM EMPLOYEE
GROUP BY
DEPT_NAME
HAVING DEPT_NAME = 'ENG';
11. AVG Function
Query 1: If we want to calculate the AVG of all the salaries in
the organization the SQL would be
SELECT AVG(SALARY) FROM EMPLOYEE
62,500
Is this what we expect????
Employee table has 7 records and the salaries are
50,000+60,000+50,000+70,000+75,000+70,000+null/7 = 53571
But we obtained 62500 from the query? Why is this so????
12. AVG (Continued….)
Remember : COUNT(*) is the only function which won’t ignore
Nulls. Other functions like SUM,AVG,MIN,MAX they ignore
Nulls. What it means is in the previous query the salary value for
a particular employee was NULL. So the query
SELECT AVG(SALARY) FROM EMPLOYEE
would ignore nulls and the way the average is calculated then would
be
50,000+60,000+50,000+70,000+75,000+70,000/6 = 62500
13. AVG (Continued….)
From the information given in the previous slide what do you think
would be the output of the following query
Select COUNT(*),COUNT(SALARY) FROM EMPLOYEE;
It would be
COUNT(*) COUNT(SALARY)
7 6
Because COUNT(*) is not going to ignore the Nulls in the result
whereas COUNT(SALARY) is going to ignore the Nulls.
14. AVG (Continued…..)
SELECT student_name,avg(mark) FROM student,enrolment
WHERE student.student_id=enrolment.student_id;
Which one of the following is correct for the query?
(a) The query is not legal
(b) The query retrieves for each student enrolled,his/her name and their
average mark
(c) The query retrieves for each student enrolled,his/her name and the clas
average mark
(d) The query retrieves for each student enrolled,his/her name and the
mark in each subject
Is the answer (a) or (b)??????
15. AVG (Continued….)
If option 1 is not given then the correct answer would be option 2.
//Script begin
Drop table student;
Drop table enrolment;
create table Student
(student_name varchar2(100),
student_id varchar2(50)
);
create table enrolment
(student_id varchar2(50),
mark number);
16. AVG (Continued….)
//Script Continued
insert into student values ('A','1');
insert into student values ('B','2');
insert into student values ('C','3');
insert into enrolment values ('1',10);
insert into enrolment values ('1',20);
insert into enrolment values ('1',30);
insert into enrolment values ('2',40);
insert into enrolment values ('2',50);
insert into enrolment values ('2',60);
insert into enrolment values ('3',70);
insert into enrolment values ('3',60);
insert into enrolment values ('3',50);
commit;
17. AVG (Continued….)
If we try to execute the query given in the question
SELECT student_name,avg(mark) FROM student,enrolment
WHERE student.student_id=enrolment.student_id;
We would get the following error in Oracle
ORA-00937:not a single-group group function
Why is it so????
18. AVG (Continued….)
Remember : When we use any of the aggregate functions in SQL
all the columns listed in the SELECT need to be part of the
GROUP BY Clause. In the previous SQL
SELECT student_name,avg(mark) FROM student,enrolment
WHERE student.student_id=enrolment.student_id;
student_name, avg(mark) are the columns included in the select.
avg is the aggregate function. So if we leave that one out then
the column which needs to part of the group by clause would be
student_name.
19. AVG (Final SQL)
The final SQL then would be
SELECT student_name,avg(mark)
FROM student,enrolment
WHERE student.student_id=enrolment.student_id
group by student_name;
Which would give out the desired output
20. Using MIN AND MAX
Query 1: To find the minimum salary within a particular
department
SELECT MIN(SALARY),NAME FROM EMPLOYEE
GROUP BY NAME;
Query 2: To find the maximum salary within a particular
department
SELECT MAX(SALARY),NAME FROM EMPLOYEE
GROUP BY NAME;