0

DBMS (SQL)

Description: SQL SQL
Number of Questions: 15
Created by:
Tags: SQL
Attempted 0/15 Correct 0 Score 0

Select a query to display the number of employees who can earn commission in department number 30.

Consider the following relation schema:
 EMP(ENAME,EMPNO,SAL,COMM,DEPTNO,JOB,MGR,HIREDATE);

  1. select count(ENAME) from EMP where DEPTNO=30 and COMM is NULL;

  2. select count(ENAME) from EMP where DEPTNO=30 and COMM is not NULL;

  3. select count(ENAME) from EMP where DEPTNO<30 and COMM is not NULL;

  4. select count(ENAME) from EMP where DEPTNO=30 and COMM has not NULL value;

  5. none of these


Correct Option: B
Explanation:

It will fetch the correct data.

Select a query to display the number of employees in department number 30.

Consider the following relation schema:
 EMP(ENAME,EMPNO,SAL,COMM,DEPTNO,JOB,MGR,HIREDATE);

  1. select count(ENAME) from EMP where DEPTNO=30;

  2. select count(EMPNO) from EMP where DEPTNO=30;

  3. select count(SAL) from EMP where DEPTNO=30;

  4. options 1 and 2

  5. none of these


Correct Option: D
Explanation:

Both the option 1 and 2 will fetch the correct data.

Select a query to display the number of departments in employee table.

Consider the following relation schema:
 EMP(ENAME,EMPNO,SAL,COMM,DEPTNO,JOB,MGR,HIREDATE);

  1. select count(distinct DEPTNO) from EMP;

  2. select count(DEPTNO) from EMP;

  3. select number(distinct DEPTNO) from EMP;

  4. select count(distinct DEPTNO) from EMP

  5. none of these


Correct Option: A
Explanation:

It will fetch the correct data, as we use count and distinct both keywords.

Select a query to display hire date of the oldest employee and the newest employee.

Consider the following relation schema:
 EMP(ENAME,EMPNO,SAL,COMM,DEPTNO,JOB,MGR,HIREDATE);

  1. select oldest(HIREDATE), newest(HIREDATE) from EMP;

  2. select old(HIREDATE), new(HIREDATE) from EMP;

  3. select max(HIREDATE), min(HIREDATE) from EMP;

  4. select max(HIREDATE), mini(HIREDATE) from EMP;

  5. options 1 and 2


Correct Option: C
Explanation:

We use max for oldest and min for newest.

Select a query to display the highest and the lowest salary for all the employees.

Consider the following relation schema ..... EMP(ENAME,EMPNO,SAL,COMM,DEPTNO,JOB,MGR,HIREDATE)...

  1. select max(SAL), min(SAL) from EMP;

  2. select high(SAL), low(SAL) from EMP;

  3. select hi(SAL), lo(SAL) from EMP;

  4. select best(SAL), min(SAL) from EMP;

  5. none of these


Correct Option: A
Explanation:

We use max keyword to get the highest value and we use min keyword to get the lowest value.

Select a query to display the average commission of employees.

Consider the following relation schema:
 EMP(ENAME,EMPNO,SAL,COMM,DEPTNO,JOB,MGR,HIREDATE);

  1. select avg(COMM) from EMP;

  2. select avg(COMM) from EMP where COMM is not NULL ;

  3. select avge(COMM) from EMP;

  4. select avg(COMM) from EMP where COMM not NULL ;

  5. options 1 and 2


Correct Option: E
Explanation:

The query of option 1 and 2 , both will fetch the  correct data.

Select a query to display the name of employees whose name ends with 'S' .

Consider the following relation schema:
 EMP(ENAME,EMPNO,SAL,COMM,DEPTNO,JOB,MGR,HIREDATE);

  1. select ENAME from EMP where ENAME like '%S' ;

  2. select ENAME from EMP where ENAME like '%%S' ;

  3. select ENAME from EMP where ENAME like 'S' ;

  4. select ENAME from EMP where ENAME like '%S%' ;

  5. none of these


Correct Option: A
Explanation:

It will fetch the correct data.

Select a query to display employee name, the number of weeks employed for all the employees in the department number 10.

Consider the following relation schema:
 EMP(ENAME,EMPNO,SAL,COMM,DEPTNO,JOB,MGR,HIREDATE);

  1. select ENAME, round(HIREDATE/7) from EMP where DEPTNO=10;

  2. select ENAME, to_day(SYSDATE-HIREDATE)*7 from EMP where DEPTNO=10;

  3. select ENAME, round((SYSDATE-HIREDATE)/7) from EMP where DEPTNO=10;

  4. select ENAME, round((SYSDATE-HIREDATE)/7) from EMP where DEPTNO=20;

  5. none of these


Correct Option: C
Explanation:

It will fetch the required data.

Select a query to display the names and hire date for all the employees who joined on February 22, 1981.

Consider the following relation schema:
 EMP(ENAME,EMPNO,SAL,COMM,DEPTNO,JOB,MGR,HIREDATE);

  1. select ENAME, HIREDATE from EMP where HIREDATE=to_date('February 22 1981','month dd yyyy');

  2. select ENAME, HIREDATE from EMP where HIREDATE=to_date('Feb 22 1981','mmm dd yyyy');

  3. select ENAME, HIREDATE from EMP where HIREDATE=to_form('February 22 1981','month dd yyyy') ;

  4. select ENAME, HIREDATE from EMP where HIREDATE=todate('Feb 22 1981','mmm dd yyyy');

  5. options 1 and 2


Correct Option: E
Explanation:

Options 1 and 2 both will fetch the correct data.

Select a query to display all the employees who are not clerks and not in department number 30.

Consider the following relation schema:
 EMP(ENAME,EMPNO,SAL,COMM,DEPTNO,JOB,MGR,HIREDATE);

  1. select ENAME from EMP where JOB not like 'CLERK' and DEPTNO not like 30

  2. select ENAME from EMP where JOB not like 'CLERK' and DEPTNO not like 30;

  3. select ENAME from EMP where JOB not as 'CLERK' and DEPTNO not as 30;

  4. select ENAME from EMP where JOB not like 'CLARK' and DEPTNO not like 30;

  5. none of these


Correct Option: B
Explanation:

It will fetch the correct data.

Select a query to display all the employees whose salary is between 1000 and 15000.

Consider the following relation schema:
 EMP(ENAME,EMPNO,SAL,COMM,DEPTNO,JOB,MGR,HIREDATE);

  1. select ENAME from EMP where SAL>=1000 or SAL<=1500;

  2. select ENAME from EMP where SAL>=1000 and SAL<=1500;

  3. select ENAME from EMP where SAL=1000 and SAL<=1500;

  4. select ENAME from EMPLOYEE where SAL>=1000 and SAL<=1500;

  5. none of these


Correct Option: B
Explanation:

The condition is appropriately emphasized, so it will give the right answer.

Select a query to display the average and sum of salaries for all employees.

Consider the following relation schema:
 EMP(ENAME,EMPNO,SAL,COMM,DEPTNO,JOB,MGR,HIREDATE);

  1. select average(SAL), sum(SAL) from EMP;

  2. select avge(SAL), sum(SAL) from EMP ;

  3. select avg(SAL), summation(SAL) from EMP;

  4. select average(SALARY), sum(SAL) from EMP;

  5. none of these


Correct Option: E
Explanation:

Yes, none of the answer is correct.

Select a query to display the employee names, their salary and manager numbers for all the employees whose manager's employee numbers are 7902, 7566, 7788.

Consider the following relation schema:
 EMP(ENAME,EMPNO,SAL,COMM,DEPTNO,JOB,MGR,HIREDATE);

  1. select ENAME, SAL, MGR, from EMP where MGR in (7902, 7566, 7788);

  2. select ENAME, SAL, MGR, from EMP where MGR =(7902, 7566, 7788);

  3. select ENAME, SAL, MGR, from EMP where MGR among (7902, 7566, 7788);

  4. select ENAME, SAL, MGR, from EMP where MGR into (7902, 7566, 7788);

  5. none of these


Correct Option: A
Explanation:

Here we are dealing with three numbers(7902, 7566, 7788), so 'in' keyword is appropriate for this.

Select a query to display the employee names, their salary along with the salary grades.

Consider the following relation schema ..... EMP(ENAME,EMPNO,SAL,COMM,DEPTNO,JOB,MGR,HIREDATE). ... SALGRADE(LOSAL,HISAL,GRADE).... [NOTE::LOSAL-HISAL (i.e. low salary and high salary ) is a range for a particular grade... as example (LOSAL=2000 HISAL=4000 then GRADE=\\'A\\' ).... ]

  1. select ENAME, SAL, GRADE from EMP where EMP.SAL between SALGRADE.LOSAL and SALGRADE.HISAL;

  2. select ENAME, SAL, GRADE from EMP,SALGRADE where EMP.SAL between SALGRADE.LOSAL and SALARY.HISAL ;

  3. select ENAME, SAL, GRADE from EMP,SALGRADE where EMP.SAL among SALGRADE.LOSAL and SALGRADE.HISAL;

  4. select ENAME, SAL, GRADE from EMP,SALGRADE where EMP.SAL between SALGRADE.LOSAL and SALGRADE.HISAL;

  5. none of these


Correct Option: D
Explanation:

LOSAL-HISAL (i.e. low salary and high salary ) is a range for a particular grade, for example (LOSAL=2000 HISAL=4000 then GRADE='A' ). So, 'between' clause is used to join both the tables.

Select a query to display employee name, job, department name, salary, and their salary grade.

Consider the following relation schema ..... EMP(ENAME,EMPNO,SAL,COMM,DEPTNO,JOB,MGR,HIREDATE). ... SALGRADE(LOSAL,HISAL,GRADE).... [NOTE::LOSAL-HISAL (i.e. low salary and high salary ) is a range for a particular grade... as example (LOSAL=2000 HISAL=4000 then GRADE=\\'A\\' ).... ]

  1. select EMP.ENAME, EMP.JOB, DEPT.DNAME, EMP.SAL, SALGRADE.GRADE from EMP, DEPT, SALGRADE where DEPT.DEPTNO=EMP.DEPTNO and EMP.SAL between SALGRADE.LOSAL and SALGRADE.HISAL;

  2. select ENAME, JOB, DNAME, SAL, GRADE from EMP, DEPT, SALGRADE where DEPT.DEPTNO=EMP.DEPTNO and EMP.SAL between SALGRADE.LOSAL and SALGRADE.HISAL;

  3. select EMP.ENAME, EMP.JOB, DEPT.DNAME, EMP.SAL, SALGRADE.GRADE from EMP, DEPT, SALGRADE where EMP.SAL between SALGRADE.LOSAL and SALGRADE.HISAL;

  4. options 1 and 2

  5. none of these


Correct Option: D
Explanation:

Option 1 and option 2 both will fetch the correct data

- Hide questions