0% found this document useful (0 votes)
6 views

Aggregate Functions in SQL

Uploaded by

ayushamber02
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Aggregate Functions in SQL

Uploaded by

ayushamber02
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Aggregate Functions in SQL

CODE
CREATE DATABASE employee;
USE employee;

CREATE TABLE employee(


id INT,
name VARCHAR(30),
salary INT,
department VARCHAR(50)
);

INSERT INTO employee


(id,name,salary,department)
VALUES
(1,"Ayush",100000,"CSE"),
(2,"Bhaskar",20000,"CSE"),
(3,"Dipanker",50000,"MECH."),
(4, "Hariom", 35000,"CIVIL"),
(5,"Jitin",60000,"CSE"),
(6,"AmberAyush",200000,"ECE"),
(7,"Aditya",150000,"AIML");

SELECT * FROM employee;

SELECT max(salary) FROM employee;


SELECT min(salary) FROM employee;
SELECT avg(salary) FROM employee;
SELECT sum(salary) FROM employee;

1|Page
SELECT count(salary) FROM employee;
SELECT id,name,department FROM employee WHERE department LIKE '%CSE';
SELECT min(salary) As SmallestSalary FROM employee;
SELECT max(salary) As MaxSalary FROM employee;

SET SQL_SAFE_UPDATES = 0;

DELETE FROM employee WHERE name='Bhaskar';


SELECT * FROM employee;

UPDATE employee
SET name="BABU" WHERE name="Dipanker";
SELECT * FROM employee;

DIFFERENT OUTPUTS
1. Print Table

2. Max Function 3. Min Function

2|Page
4. Avg Function 5. Sum Function

6. Count Function 7. Like Command

8. Alias Function 9. Alias Function

10. Delete Tuple

11.Update Tuple

3|Page

You might also like