SQL query In DBMS

Hello Everyone Myself Gautam, In This post i m going to solve 25 SQL Query,  

1. Display all the information of the emp table.
Ans:- SELECT * FROM EMP;


 2. Display unique jobs from EMP table.
Ans:- SELECT DISTINCT JOB FROM EMP;


 3. List the details of the employees in asc order of their salaries.
Ans:- SELECT * FROM EMP ORDER BY SAL ASC;


 4. List the details of the emps in asc order of the Deptnos and desc of Jobs.
Ans:-  SELECT * FROM EMP ORDER BY DEPTNO ASC,JOB DESC;


 5. Display all the unique job groups in the descending order 
Ans:- SELECT DISTINCT JOB FROM EMP ORDER BY JOB DESC;


6. Display all the details of all ‘Manager’ 
Ans:- Select * from emp where empno in ( select mgr from emp) ;


7. List the emps who joined before 1981. 
Ans:- select * from emp where hiredate < ('01-jan-81’);


8. List the Empno, Ename, Sal, Daily Sal of all Employees in the ASC order of AnnSal. 
Ans:-  select empno ,ename ,sal,sal/30,12*sal annsal from emp order by annsal asc;


 9. Display the empno , ename, job, hiredate, exp of all Mgrs 
Ans:-  select empno,ename ,job,hiredate, months_between(sysdate,hiredate) exp from emp where empno in (select mgr from emp);


10. List the empno, ename, sal, exp of all emps working for Mgr 7839. 
Ans:-  select empno,ename,sal,exp from emp where mgr = 7839;


 11. Display the details of the emps whose Comm. Is more than their sal. 
Ans:-  select * from emp where comm. > sal;


12. List the emps in the asc order of Designations 
Ans:-  select * from emp order by job asc;


13. List the emps along with their exp and daily sal is more than Rs.100 
Ans:- select * from emp where (sal/30)>100;


 14. List the emps who are either ‘CLERK’ or ‘ANALYST’ in the desc order 
Ans:- select * from emp where job='CLEARK' or job='ANALYST' order by job desc;


15. List the emps who joined on 1May81, 31Dec81, 17Dec81, 19Jan80 in asc order of seniority. 
Ans:- select * from emp where hiredate in('1-may-81','31-dec-81','17-dec-81','19-jan-80') order by hiredate asc;


16. List the emps who are working for the deptno 10 or 20 
Ans:- select * from emp where deptno=10 or deptno=20;


 17. List the emps who are joined in the year 1981 
Ans:- select * from emp where hiredate between ('01-jan-81' and '31-dec-81');


18. List the emps who are joined in the month of Aug 1980 
Ans:-  select * from emp where hiredate between '01-aug-80' and '31-aug-80';


19. List the emps whose annul sal ranging from 22000 and 45000 
Ans:- select * from emp where 12*sal between 22000 and 45000;


20. List the emps those are having five characters in their names. 
Ans:- select ename from emp where length(ename)=5;


21. List the enames those are starting with ‘s’ and with fire characters 
Ans:- select ename from emp where ename like 's%' and length(ename)=5;


22. List the emps those are having four chars and third char must be ‘r’ 
Ans:- select * from emp where length(ename)=4 and ename like '__r%';


23. List the 5 character names starting with ‘s’ and ending with ‘h’ 
Ans:-  select * from emp where length(ename)=5 and ename like 's%h';


 24. List the emps who joined in January 
Ans:-select * from emp where to_char(hiredate,'mon') like 'jan';


25. List the emps who joined in the month of which second character is ‘a’
Ans:- select * from emp where to_char(hiredate,'mon') like '_a_';





Social media link:

 Please Follow me in Instagram:-  Click Here

Please Follow me and Share this page 


THANKS FOR VISITING THIS BLOG PAGE 💖.



Post a Comment

0 Comments