Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
21Activity
0 of .
Results for:
No results containing your search query
P. 1
SQL Queries

SQL Queries

Ratings: (0)|Views: 502 |Likes:
Published by minuvarsha0

More info:

Published by: minuvarsha0 on Nov 26, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

09/29/2010

pdf

text

original

 
SQL Queries
1)Display the details of all employeesa)select * from emp;2)Display the depart informaction fromdepartment tablea)select * from dept;3)Display the name and job for all the employeesa)select ename,job from emp;4)Display the name and salary for all theemployeesa)select ename,sal from emp;5)Display the employee no and totalsalary for allthe employeesa)select empno,sal+comm as total from empgroup by empno;6)Display the employee name and annual salaryfor all employees.a)select ename,sal * 12 as annualsalary fromemp;7)Display the names of all the employees who areworking in departnumber 10.a)select emame from emp where deptno=10;8)Display the names of all the employees who areworking as clerks anddrawing a salary more than 3000.a)select ename from emp where job='CLERKS'and sal>3000;9)Display the employee number and name whoare earning comm.a)select empno,ename from emp where comm isnot null;10)Display the employee number and name whodo not earn any comm.a)select empno,ename from emp where comm isnull;11)display the names of employees who areworking as clerks,salesman oranalyst and drawing a salary more than 3000.A)select ename from emp where job='CLERK' OR JOB='SALESMAN' OR JOB='ANALYST' AND SAL>3000;12)display the names of the employees who areworking in the companyfor the past 5 years;a)select ename from emp whereto_char(sysdate,'YYYY')-to_char(hiredate,'YYYY')>=5;13)Display the list of employcees who have joinedthe company before30-JUN-90 or after 31-DEC-90.a)select ename from emp where hiredate < '30- JUN-1990' or hiredate >'31-DEC-90';14)Display current Date.a)select sysdate from dual;15)Display the list of all users in yourdatabase(use catalog table).a)select username from all_users;16)Display the names of all tables from currentuser;a)select tname from tab;17)Display the name of the current user.a)show user18)Display the names of employees working indepart number 10 or 20 or40 or employees working as CLERKS, SALESMANor ANALYST.a) Select ename from emp where deptnoin(10,20,40) or jobin('CLERKS','SALESMAN','ANALYST');19) Display the names of employees whose namestarts with alphabet S.a)select ename from emp where ename like 'S%';20) Display the Employee names for employeeswhose name ends with Alphabet S.a) Select ename from emp where ename like'%S';21) Display the names of employees whosenames have second alphabet A in their names.a) Select ename from EMP where ename like '_A%';22) select the names of the employee whosenames is exactly fiveCharacters in length.a) select ename from emp wherelength(ename)=5;23) Display the names of the employee who arenot working as MANAGERS.a) Select ename from emp where job not in('MANAGER');24)Display the names of the employee who arenot working as SALESMAN OR CLERK ORANALYST.A)select ename from emp where job notin('SALESMAN','CLERK','ANALYST');25) Display all rows from EMP table. The systemshould wait after every Screen full of information.a) Set pause on
 
26) Display the total number of employee workingin the company.a) Select count (*) from EMP;27) Display the total salary beiging paid to allemployees.a)select sum(sal) from emp;28)Display the maximum salary from emp table.a)select max(sal) from emp;29)Display the minimum salary from emp table.a)select min(sal) from emp;30)Display the average salary from emp table.a)select avg(sal) from emp;31)Display the maximum salary being paid toCLERK.a)select max(sal) from emp where job='CLERK';32)Display the maximum salary being paid todepart number 20.a)select max(sal) from emp where deptno=20;33)Display the minimum salary being paid to anySALESMAN.a)select min(sal) from emp where job='SALESMAN';34)Display the average salary drawn byMANAGERS.a)select avg(sal) from emp where job='MANAGER';35)Display the total salary drawn by ANALYSTworking in depart number40.a)select sum(sal) from emp where job='ANALYST'and deptno=40;36)Display the names of the employee in order of salary i.e the name of the employee earning lowest salary should salaryappear first.a)select ename from emp order by sal;37)Display the names of the employee indescending order of salary.a)select ename from emp order by sal desc;38)Display the names of the employee in order of employee name.a)select ename from emp order by ename;39)Display empno,ename,deptno,sal sort theoutput first base on nameand within name by deptno and with in deptno bysal.a)
selectempno,ename,deptno,salfromemp order byename,deptno,sal
40)Display the name of the employee along withtheir annual salary(sal*12).The nameof the employee earning highest annual salaryshould apper first.a)select ename,sal*12 from emp order by saldesc;41)Display name,salary,hra,pf,da,total salary foreach employee. Theoutput should be inthe order of total salary,hra 15% of salary,da 10%of salary,pf 5%salary,total salary will be(salary+hra+da)-pf.a)select ename,sal,sal/100*15 as hra,sal/100*5 aspf,sal/100*10 asda,sal+sal/100*15+sal/100*10-sal/100*5 as totalfrom emp;42)Display depart numbers and total number of employees working in eachdepartment.a)select deptno,count(deptno)from emp group bydeptno;43)Display the various jobs and total number of employees within each job group.a)select job,count(job)from emp group by job;44)Display the depart numbers and total salaryfor each department.a)select deptno,sum(sal) from emp group bydeptno;45)Display the depart numbers and max salaryfor each department.a)select deptno,max(sal) from emp group bydeptno;46)Display the various jobs and total salary foreach joba)select job,sum(sal) from emp group by job;47)Display the various jobs and total salary foreach joba)select job,min(sal) from emp group by job;48)Display the depart numbers with more thanthree employees in eachdept.a)select deptno,count(deptno) from emp group bydeptno havingcount(*)>3;49)Display the various jobs along with total salaryfor each of the jobs where total salary is greater than 40000.a)select job,sum(sal) from emp group by jobhaving sum(sal)>40000;50)Display the various jobs along with totalnumber of employees ineach job.The output should contain only those jobs with more than threeemployees.
 
a)select job,count(empno) from emp group by jobhaving count(job)>351)Display the name of the empployee who earnshighest salary.a)select ename from emp where sal=(selectmax(sal) from emp);52)Display the employee number and name foremployee working as clerkand earning highest salary among clerks.a)select empno,ename from emp where where job='CLERK' and sal=(selectmax(sal) from emp where job='CLERK');53)Display the names of salesman who earns asalary more than thehighest salary of any clerk.a)select ename,sal from emp where job='SALESMAN' and sal>(selectmax(sal) from emp where job='CLERK');54)Display the names of clerks who earn a salarymore than the lowestsalary of any salesman.A)select ename from emp where job='CLERK' andsal>(select min(sal) fromemp where job='SALESMAN');55)Display the names of employees who earn asalary more than that of  Jones or that of salary grether than that of scott.a)select ename,sal from emp where sal>(select sal from emp where ename='JONES')andsal> (select sal from empwhere ename='SCOTT');56)Display the names of the employees who earnhighest salary in theirrespective departments.a)select ename,sal,deptno from emp where salin(select max(sal) fromemp group by deptno);57)Display the names of the employees who earnhighest salaries intheir respective job groups.a)select ename,sal,job from emp where salin(select max(sal) from empgroup by job)58)Display the employee names who are workingin accounting department.a)select ename from emp where deptno=(selectdeptno from dept wheredname='ACCOUNTING')59)Display the employee names who are workingin Chicago.a)select ename from emp where deptno=(selectdeptno from dept whereLOC='CHICAGO')60)Display the Job groups having total salarygreater than the maximumsalary for managers.a)SELECT JOB,SUM(SAL) FROM EMP GROUP BY JOBHAVING SUM(SAL)>(SELECTMAX(SAL) FROM EMP WHERE JOB='MANAGER');61)Display the names of employees fromdepartment number 10 with salarygrether than that of any employee working inother department.a)select ename from emp where deptno=10 andsal>any(select sal from empwhere deptno not in 10).62)Display the names of the employees fromdepartment number 10 withsalary greater than that of all employee workingin other departments.a)select ename from emp where deptno=10 andsal>all(select sal from empwhere deptno not in 10).63)Display the names of the employees inUppercase.a)select upper(ename)from emp64)Display the names of the employees inLowecase.a)select lower(ename)from emp65)Display the names of the employees inPropercase.a)select initcap(ename)from emp;66)Display the length of Your name usingappropriate function.a)select length('name') from dual67)Display the length of all the employee names.a)select length(ename) from emp;68)select name of the employee concatenate withemployee number.select ename||empno from emp;69)User approprate function and extract 3characters starting from 2characters from the following string 'Oracle'. i.ethe out put should be'ac'.a)select substr('oracle',3,2) from dual70)Find the First occurance of character 'a' fromthe following stringi.e 'Computer Maintenance Corporation'.a)SELECT INSTR('Computer MaintenanceCorporation','a',1) FROM DUAL71)Replace every occurance of alphabhet A withB in the stringAllens(use translate function)a)select translate('Allens','A','B') from dual72)Display the informaction from emptable.Where job manager is found

Activity (21)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
Dinesh Bhawnani liked this
Nazeer Ahammed liked this
Nazeer Ahammed liked this
vinay712 liked this
Dinesh Bhawnani liked this
Dinesh Bhawnani liked this
A Alagu Ganesh liked this
A Alagu Ganesh liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->