Sei sulla pagina 1di 9

SQL QUERIES

Employee(e_id , e_name , salary,commision, job,d_no)

Createing table: create table employee (eid number(5), ename varchar(20), sal number(10), comm
number(10), job varchar(10), dno number(5));

Query:

1.select table.

2. display everyone in dept no 20 who is neither a clark,salesman nor analyst.

Query: select * from emp where d_no = 20 and job not in ('clerk','salesman','analyst');
SQL QUERIES

3. list all emp names,their jobs,salary in ascending order by their jobs.

Query: select ename,job,sal from employee order by job;

4. list emp noand names who are managers.

Query: select eid, ename from employee where job = 'manager';

5.display names of all emp whose comm is grater than salary.

Query: select ename from employee where comm > (select sal from employee);
SQL QUERIES

6. to find the sum paid as salary to all emp every month.

Query: select sal*12, ename as salary from employee;

7.display emp name,salary whose salary is grater than that of all managers.

Query: select ename, sal from employee sal > (select sal from employee where job = 'manager');
SQL QUERIES

8. display emp name,salary whose salary is grater than that of any managers of any dept.

Query: select ename, sal from employee sal < (select sal from employee where job = 'manager');

9.to find minimum salary of managers in various depts..


SQL QUERIES

Query: select min(sal),dno from employee group by dno;

10.give list of all emp along with theirs monthly and annual income.

Query: select ename,sal as monthly income,sal*12 as annual income from employee;


SQL QUERIES

11.display emp whose salary between 10000 and 30000 both inclusive.

Select * from employee where salary >=10000 and salary =<30000;

12.find min salary of managers in various dept having salary > 20000
SQL QUERIES

13. display details of emp with annual salary and sort data on basis of annual salary.

14.find emp who have same job title in dept no 10 and 20


SQL QUERIES

15. find emp name who having the job in dept 10 but not in 20.

employee(e_no,e_name,d_no,job,hiredate)
(a)e_no number(20) primary key

(b) e_no number(20) primary key not null

(c) hdate date defult sysdate not null

dept(d_no,d_name,loc)

(a) d_no number(20) primary key


(b) d_name varchar(20) not null, loc number(10) not null
(c) references: create table employee (e_no number(10) primary key not null,e_name varchar
(20),d_no number(10), job varchar(20), hdate date default sysdate not null, constraint fk_emp
foreign key(d_no) references dept(d_no));
SQL QUERIES

Potrebbero piacerti anche