The document contains a series of SQL queries related to employee and student data management. It includes various SELECT statements for retrieving employee information, salary calculations, and aggregate functions, as well as commands for creating, inserting, updating, and deleting student records. Additionally, it demonstrates the use of JOIN operations to combine data from employees and departments.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2 views8 pages
Postgress Notes
The document contains a series of SQL queries related to employee and student data management. It includes various SELECT statements for retrieving employee information, salary calculations, and aggregate functions, as well as commands for creating, inserting, updating, and deleting student records. Additionally, it demonstrates the use of JOIN operations to combine data from employees and departments.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8
select * from employees
Select first_name,last_name from employees
select salary,salary*.9"after TDS" from employees select salary,salary* -.1"TDS",salary*.9"after TDS" from employees select salary,salary* -.1"TDS",salary*.9"after TDS" from employees select distinct first_name from employees
select * from employees
Select first_name ||' ' || last_name || ' ' || 'is earning' || ' ' || salary from employees --this is an example of concat Select salary from employees Select first_name || ' is earning ' || salary from employees Select salary, commission_pct from employees
Select salary, commission_pct, salary * commission_pct "Incentives" from employees
Select * from employees
Select first_name from employees
Select last_name,first_name from employees Select first_name ||' ' || last_name from employees Select first_name ||' ' || last_name "Full Candidate Name" from employees Select first_name ||' ' || last_name "Full Candidate Name" from employees --this is an example of concat Select first_name ||' ' || last_name || ' ' || 'is earning' || ' ' || salary from employees Select salary, commission_pct from employees
Select salary, commission_pct, salary * commission_pct "Incentives" from employees
select distinct job_id from employees select count(*) from employees this is a aggregate function other aggregate functions are count, min, max, sum, average select count(first_name) from employees
select first_name, count(*) from employees it is an error as there is no symmetry in the
table
Select * from employees where last_name like 'A%'
SELECT count(*) FROM employees
Select * from employees
where salary <=10000;
Select first_name, salary from employees
where first_name like 'A%' AND salary >10000;
Select * from employees
where salary > 10000;
Select salary,commission_pct from employees
where salary >10000;
select sum(salary) from employees
where salary>10000
select count(salary) from employees
where salary>10000
Select count(commission_pct) from employees
where salary >10000;
select sum(salary) from employees
where commission_pct=.1
Select first_name||' ' || last_name "Full Name",commission_pct*100 ||'%'"Incentives" from
employees where commission_pct<= .2;
Select first_name || ' ' ||last_name from employees
where salary>=10000; select salary from employees where salary >= 5000 or salary <= 10000;
select salary,commission_pct from employees
where salary >=10000 and commission_pct is NULL
Select sum(salary) from employees
where first_name = 'Alexander';
Select first_name from employees
where first_name like '_i%'
Select first_name from employees
where first_name like '_i%a_'
Select first_name from employees
where first_name like '%_i' order by first_name desc
Select job_id, sum(salary) from employees
group by job_id Select job_id, count(*) from employees group by job_id
select first_name, count(*)"CNT" from employees
GROUP by first_name having count(*)>1 order by "CNT" DESC
select first_name from employees
GROUP by first_name having count(*)>1
sELECT job_id,count(job_id),sum(salary) "total_sal" from employees
where commission_pct is not Null group by job_id having sum(salary)>=65000 order by total_sal desc
Select first_name, last_name, department_name, location_id from employees a join departments
b on a.department_id = b.department_id where location_id >= 2400 order by location_id Select first_name, last_name, department_name from employees a join departments b on a. manager_id = b. manager_id where department_name = 'Marketing'
select * from departments where location_id >= 2400
Select first_name,last_name,department_name from employees a join departments b
on a.manager_ = b. department_id where a.department_id = 40 or a.department_id = 70 or a.department_id = 80;
select * from employees where department_id = 150
select * from departments
Create table student (
stdid int primary key, fn varchar(20), gender char, age int )
Select * from student
insert into student values ( 101, 'Tushar','M',23)
insert into student values (98, 'Tushar 1', 'M', 24)
drop table student
Create table student (
stdid int primary key, fn varchar(20), gender char, age int )
Select * from student
insert into student values ( 101, 'Tushar','M',23)
insert into student values (98, 'Tushar 1', 'M', 24)