Query & Answer
Query & Answer
Table Creations:
create table dept (deptno number primary key, dname varchar2(20), loc varchar2(15));
insert into dept values (&deptno, ’&dname’, ’&loc’);
create table emp (empno number primary key, ename varchar2(15), job varchar2(15), mgr
number, hiredate date, sal number, comm number, deptno number, foreign key(deptno)
references dept(deptno));
insert into emp values (&empno, ’&ename’, ’&job’, &mgr, to_date(‘&hiredate’,’DD-MON-
YY’), &sal, &comm, &deptno);
Queries
Retrieve all the enames from the emp.
Retrieve all the emp names and salary who are earning more than 3000.
List out all the emp names and dept no who are working in dept no 10.
Retrieve all the emp names and jobs who are working as analyst.
List out the manager number for emp ‘smith’.
Select all the emp names and jobs who are getting comm.
Retrieve all the emp names, salary and comm whose comm is greater
than their salary.
Retrieve all the emp details in deptno 20 and who are working as
clerk’.
Retrieve all the emp details in deptno 20 or who are working as ‘clerk’.
List out all the emp details in deptno 30 and who are earning more than
1000.
List out all the dept’s whose deptno is greater than 10.
List out all the employees who are joined on the ’28-sep-1981’.
List out all the emp names in descending order.
List out all the information who are in deptno 10 and 20.
List out all the information who are earning salary from 1000 to 2000.
List out all the emps whose names are starting with letter ‘a’.
List out all the information whose jobs ends with letter ‘T’.
List out all the information of emp except president in ascending order of
salary.
List out emp in below format ‘SMITH is working as CLERK’.