0% found this document useful (0 votes)
3 views1 page

Create Database Org

The document outlines SQL commands for creating a database named 'org' and a table 'employee' with various attributes. It includes commands for inserting employee records, querying salary data with conditions, and performing aggregate functions like SUM, MAX, AVG, and COUNT. Additionally, it explains the usage of WHERE and HAVING clauses in SQL queries.

Uploaded by

ar703232
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Create Database Org

The document outlines SQL commands for creating a database named 'org' and a table 'employee' with various attributes. It includes commands for inserting employee records, querying salary data with conditions, and performing aggregate functions like SUM, MAX, AVG, and COUNT. Additionally, it explains the usage of WHERE and HAVING clauses in SQL queries.

Uploaded by

ar703232
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

create database org;

use org;
create table employee(emp_ID int unique, emp_Name varchar(50), Dept varchar(20),
Salary int, DOJ date, Loc varchar(50), Gender varchar(10));

insert into employee values


(100,'arun', 'IT', 450000,'2025-08-18', 'Hyderabad', 'M'),
(101,'prasad', 'SP', 25000,'2025-08-18', 'Hyderabad', 'F'),
(102,'ankita', 'IT', 250000,'2025-08-18', 'Hyderabad', 'F'),
(103,'raghavi', 'HR', 150000,'2025-08-18', 'Hyderabad', 'M'),
(104,'mahesh', 'N-IT', 15000,'2025-08-18', 'Hyderabad', 'M'),
(105,'rahul', 'N-IT', 15000,'2025-08-18', 'Hyderabad', 'M');

select * from employee;


/*in order to use grp by and where clause in one place, first where clause should
be used then grp by clause*/
select Dept,SUM(Salary) as salary from employee where Salary>100000 group by Dept;
/*Having clause can only be used after grp by clause, having cluse can not be used
individually*/

select sum(salary) as total_salary from employee;

select max(salary) from employee;

select AVG(salary) from employee;

select count(salary) from employee;

select * from employee where salary in (select max(salary) from employee);

You might also like