Showing posts with label sql tips for beginners. Show all posts
Showing posts with label sql tips for beginners. Show all posts

Tuesday, 22 September 2015

SQL Interview Queries frequently asked for fresher's |Sql Interview Questions2

- 1 comments


SQL Queries frequently asked in interviews for fresher's based on Employee table.

Sql interview Questions for freshers ,all sql queries for the beginners ,sql Questionss and Answers are given bellow .

SQL Queries on Employee table EMP and Department Table DEPT :

Sql Interview Questions|sql


EMP : Employee Table DEPT :Department Table



Q21 : What is the Query  to List the Enames those are starting with ‘S’ and with five characters?

Answer:select ename from emp where ename like ‘S%’ and length (ename) =5;

Q 22 : What is the Query to List out the emps those are having four chars and third character must be ‘r’?

Answer :  select * from emp where length(ename) = 4 and ename like ‘__R%’;

Q 23 : What is the Query for to List out the Five character names starting with ‘S’ and ending with ‘H’?

Answer :  select * from emp where length(ename) = 5 and ename like ‘S%H’;

Q 24 : What is the Query for to List out the emps who joined in January.

Answer :  select * from emp where to_char (hiredate,’mon’) = ‘jan’;

Q 25 : What is the Query for List out the emps who joined in the month of which second character is ‘a’?

Answer : 

select * from emp where to_char(hiredate,’mon’) like ‘_a_’;  

                                {or}

select * from emp where to_char(hiredate,’mon’) like ‘_a%’;

Q 26 : What is the Query for List the emps whose Sal is four digit number ending with Zero?

Answer :  select * from emp where length (sal) = 4 and sal like ‘%0’;

Q 27 : What is the Query for List the emps whose names having a character set ‘ll’ together?

Answer :  select * from emp where ename like ‘%LL%’;

Q 28 : What is the Query for to List out the emps those who joined in 80’s?

Answer : select * from emp where to_char(hiredate,’yy’) like ‘8%’;

Q 29 : What is the Query for to List the emps who does not belong to Deptno 20 ?

Answer : select * from emp where deptno not in (20); {or}

select * from emp where deptno != 20;  {or}

select * from emp where deptno not like ‘20’;

Q 30 : What is the Query for to List all the emps except ‘PRESIDENT’ & ‘MGR” in asc order of Salaries.

Answer : Select * from emp where job not in (‘PRESIDENT’,’MANAGER’) order by sal asc;  {or}

select * from emp where job not like ‘PRESIDENT’ and job not like ‘MANAGER’ order by sal asc;

Q 31 : What is the Query for to List all the emps who joined before or after 1981?

select * from emp where to_char(hiredate,’YYYY’) <> ‘1981’ ; {or}

Answer : select * from emp where to_char (hiredate,’YYYY’) not in (‘1981’); {or}

select * from emp where to_char ( hiredate,’YYYY’) != ‘1981’; {or}

select * from emp where to_char (hiredate ,’YYYY’) not like ‘1981’;  

Q 32 : What is the Query for to List the emps whose Empno not starting with digit78?

Answer : select * from emp where empno not like ‘78%’;

Q 33 : What is the Query for List the emps who are working under ‘MGR’.

 Answer :  select e.ename || ‘ has an employee ‘|| m.ename from emp e , emp m where e.empno = m.mgr; {or}

select e.ename || ‘ works for ‘ || m.ename from emp e ,emp m where e.mgr = m.empno ;

Q 34 : What is the Query for List the emps who joined in any year but not belongs to the month of March?

Answer :  select * from emp where to_char (hiredate,’MON’) not in (‘MAR’); {or}

select * from emp where to_char (hiredate,’MON’) != ‘MAR’; {or}

select * from emp where to_char(hiredate,’MONTH’) not like ‘MAR%’ ;

Q 35 : What is the Query for to List all the Clerks of Deptno 20?

Answer :  select * from emp where job =‘CLERK’ and deptno = 20;

Q 36 : What is the Query for

List the emps of Deptno 30 or 10 joined in the year 1981?

Answer :  select * from emp where to_char(hiredate,’YYYY’) = ‘1981’ and (deptno =30 or deptno =10) ; {or}select * from emp where to_char (hiredate,’YYYY’) in (‘1981’) and (deptno = 30 or deptno =10 ) ;

Q 37 : What is the Query for to Display the details of SMITH?

Answer :  select * from emp where ename = ‘SMITH’ ;

Q 38 : What is the Query for to Display the location of SMITH?

Answer :  

select loc from emp e , dept d where e.ename = ‘SMITH’ and e.deptno = d.deptno ;

Q 39 : What is the Query for to List the total information of EMP table along with DNAME and Loc of all the emps Working Under ‘ACCOUNTING’ & ‘RESEARCH’ in the asc Deptno ?

Answer :  select * from emp e ,dept d where (dname = ‘ACCOUNTING’ or dname =’RESEARCH’ ) and e.deptno = d.deptno order by e.deptno asc; {or}

select * from emp e ,dept d where d.dname in (‘ACCOUNTING’,’RESEARCH’) and e.deptno = d.deptno order by e.deptno asc;

Q 40 : What is the Query for to List the Empno, Ename, Sal, Dname of all the ‘MGRS’ and ‘ANALYST’ working in New York, Dallas with an exp more than 7 years without receiving the Comm asc order of Loc?

Answer :  select e.empno,e.ename,e.sal,d.dname from emp e ,dept d where d.loc in (‘NEW YORK’,’DALLAS’) and e.deptno = d.deptno and e.empno in (select e.empno from emp e where e.job in (‘MANAGER’,’ANALYST’) and (months_between(sysdate,e.hiredate)/12)> 7 and e.comm. is null) order by d.loc asc;



Tags:  important sql queries for beginners , Sql Queries and Answers ,Sql Queries asked in interview , important sql queries, frequently asked in interviews for fresher's based on Employee table, All Sql Queries on emp and dept tables wipro frequently asked Questions , employee table related queries , Sql Queries on dept table and employee tables ,frequently asked interview Questions on Sql Queries, Sql Queries for fresher's to crack the interview ,SQL Questions and answers for the frequently asked interviews, what is the query for the to display employee details , Interview Questions for freshers to crack their technical round.  


NOTE: Post your sql queries as a comments we will give answers our best.
[Continue reading...]

SQL Questions frequently asked in interviews for freshers based on Employee table|Sql Interview Questions

- 2 comments
SQL Questions frequently asked in interviews for freshers based on Employee table .
Sql interview Questions for freshers ,all sql queries for the beginners ,sql Questions and Answers are given bellow . 
Sql Interview Questions
SQL Queries on Employee table EMP and Department Table DEPT :
EMP : Employee Table DEPT :Department Table
Q 1 : What is the Query for to Display all the information of the EMP  table?
Answer :  select * from emp;
the syntax for the selecting any table is Select * from (Table Name);
Q 2 : What is the Query for to Display unique Jobs from EMP table?
Answer :  select distinct job from emp;
 similar query for this Query is
    select unique job from emp;

Q 3 : What is the Query for to List out the emps in the asc order of their Salaries?
Answer :  select * from emp order by sal asc;
Q 4 : What is the Query for to List out the details of the emps in asc order of the Dptno's and desc of Jobs?
Answer :  select * from emp order by deptno asc,job desc;
Q 5 : What is the Query for to Display all the unique job groups in the descending order?
Answer :  select distinct job from emp order by job desc;
Q 6 : What is the Query for to Display all the details of all ‘Mgrs’ ?
 Answer :  Select * from emp where empno in ( select mgr from emp) ;
Q 7 : What is the Query for List the emps who joined before 1981?
Answer :  select * from emp where hiredate < (’01-jan-81’);
Q 8 : What is the Query for to List the Empno, Ename, Sal, Daily sal of all emps in the asc order of Annsal ?
Answer : select empno ,ename ,sal,sal/30,12*sal annsal from emp order by annsal asc;
Q 9 : What is the Query for to Display the Empno, Ename, job, Hiredate, Exp of all Mgrs ?
Answer : select empno,ename ,job,hiredate, months_between(sysdate,hiredate) exp from emp where empno in (select mgr from emp);
Q 10 : What is the Query for to List the Empno, Ename, Sal, Exp of all emps working for Mgr 7369 ?
 Answer : select empno,ename,sal,exp from emp where mgr = 7369;
Q 11 : What is the Query for to Display all the details of the emps whose Comm. Is more than their Sal ?
Answer :select * from emp where comm. > sal;
Q 12 : What is the Query for to List the emps in the asc order of Designations of those joined after the second half of 1981?

Answer :select * from emp where hiredate > (’30-jun-81’) and to_char(hiredate,’YYYY’) = 1981 order by job asc;
Q 13 : What is the Query for to List the emps along with their Exp and Daily Sal is more than Rs.100?
Answer :  select * from emp where (sal/30) >100;
Q 14 : What is the Query for to List the emps who are either ‘CLERK’ or ‘ANALYST’ in the Desc order ?
Answer :  select * from emp where job = ‘CLERK’ or job = ‘ANALYST’ order by job desc;
Q 15 : What is the Query for to List the emps who joined on 1-MAY-81,3-DEC-81,17-DEC-81,19-JAN-80 in asc order of seniority?
Answer :  select * from emp where hiredate in (’01-may-81’,’03-dec-81’,’17-dec-81’,’19-jan-80’) order by hiredate asc;
Q 16 : What is the Query for to List the emp who are working for the Deptno 10 or20 ?
Answer :  select * from emp where deptno = 10 or deptno = 20 ;
Q 17 : What is the Query for to List the emps who are joined in the year 81 ?
Answer :  select * from emp where hiredate between ’01-jan-81’ and ’31-dec-81’;
Q 18 : What is the Query for to List the emps who are joined in the month of Aug 1980 ?
Answer :  
select * from emp where hiredate between ’01-aug-80’ and ’31-aug-80’; (OR)
select * from emp where to_char(hiredate,’mon-yyyy’) =’aug-1980;
Q 19 : What is the Query for to List the emps Who Annual sal ranging from 22000 and 45000 ?
Answer :  select * from emp where 12*sal between 22000 and 45000;
Q 20 : What is the Query for to List the Enames those are having five characters in their Names ?
Answer :  select ename from emp where length (ename) = 5;
Tags: Sql Queries and Answers , Sql Queries on employee , Sql Queries asked in interview , All SQL Questions(Queries) frequently asked in interviews for fresher's based on Employee table, All Sql Queries on emp and dept tables wipro frequently asked Questions , employee table related queries , Sql Queries on dept table and employee tables ,frequently asked interview Questions on Sql Queries, Sql Queries for fresher's to crack the interview ,SQL PLUS Questions ,SQL Questions and answers for the frequently asked interviews, what is the query for the to display employee details , Interview Questions for freshers to crack their technical round.  

NOTE: Post your sql queries as a comments we will give answers as our best.

[Continue reading...]
 
Copyright © . MSBI SQL SERVER SSIS SSRS INTERVIEW TIPS - Posts · Comments
Theme Template by BTDesigner · Powered by Blogger