SQL For Testing Professional
SQL For Testing Professional
Smoke Testing: Software Testing done to ensure that whether the build can be accepted for through
software testing or not. Basically, it is done to check the stability of the build received for software
testing.
Sanity testing: After receiving a build with minor changes in the code or functionality, a subset of
regression test cases are executed that to check whether it rectified the software bugs or issues and
no other software bug is introduced by the changes. Sometimes, when multiple cycles of regression
testing are executed, sanity testing of the software can be done at later cycles after through
regression test cycles. If we are moving a build from staging / testing server to production server,
sanity testing of the software application can be done to check that whether the build is sane enough
to move to further at production server or not.
Smoke testing is a wide approach where all areas of the software application are tested
without getting into too deep. However, a sanity software testing is a narrow regression
testing with a focus on one or a small set of areas of functionality of the software application.
The test cases for smoke testing of the software can be either manual or automated.
However, a sanity test is generally without test scripts or test cases.
Smoke testing is done to ensure whether the main functions of the software application are
working or not. During smoke testing of the software, we do not go into finer details. However,
sanity testing is a cursory software testing type. It is done whenever a quick round of software
testing can prove that the software application is functioning according to business / functional
requirements.
Smoke testing of the software application is done to check whether the build can be accepted
for through software testing. Sanity testing of the software is to ensure whether the
requirements are met or not.
Question 1: SQL Query to find second highest salary of Employee
SELECT GetDate();
Question 4: Write an SQL Query to check whether date passed to Query is the date of given format
or not.
3. Get First_Name from employee table using alias name Employee Name
9. Get FIRST_NAME from employee table after removing white spaces from
right side
10. Get FIRST_NAME from employee table after removing white spaces from
left side
13. Get First_Name and Last_Name as single column from employee table
separated by a '_'
SQL Server Equivalent of MySQL concat is '+', Query : Select FIRST_NAME + '_'
14. Get FIRST_NAME ,Joining year,Joining Month and Joining Date from
employee table
(convert(varchar,joining_date,103),7,4) , SUBSTRING
(convert(varchar,joining_date,100),1,3) , SUBSTRING
15. Get all employee details from the employee table order by First_Name Ascending
Select * from employee order by FIRST_NAME asc
16. Get all employee details from the employee table order by First_Name
descending
17. Get all employee details from the employee table order by First_Name Ascending
and Salary descending
19. Get employee details from employee table whose employee name are John and
Roy
20. Get employee details from employee table whose employee name are not John
and Roy
22. Get employee details from employee table whose first name contains 'o'
23. Get employee details from employee table whose first name ends with 'n'
24. Get employee details from employee table whose first name ends with 'n'
and name contains 4 letters
25. Get employee details from employee table whose first name starts with 'J'
and name contains 4 letters
26. Get employee details from employee table whose Salary greater than
600000
27. Get employee details from employee table whose Salary less than 800000
28. Get employee details from employee table whose Salary between 500000
and 800000
29. Get employee details from employee table whose name is 'John' and
'Michael'
30. Get employee details from employee table whose joining year is 2013
to_char(joining_date,'YYYY')='2013'
SQL Queries in SQL Server, Select * from EMPLOYEE where
SUBSTRING(convert(varchar,joining_date,103),7,4)='2013'
31. Get employee details from employee table whose joining month is
January
SQL Queries in Oracle, Select * from EMPLOYEE where
to_char(joining_date,'Mon')='Jan'
SUBSTRING(convert(varchar,joining_date,100),1,3)='Jan'
32. Get employee details from employee table who joined before January 1st
2013
SQL Queries in Oracle, Select * from EMPLOYEE where JOINING_DATE
<to_date('01/01/2013','dd/mm/yyyy')
joining_date <'2013-01-01'
33. Get employee details from employee table who joined after January 31st
SQL Queries in Oracle, Select * from EMPLOYEE where JOINING_DATE
>to_date('31/01/2013','dd/mm/yyyy')
SQL Queries in SQL Server and MySQL (Format - MM/DD/YYYY), Select * from
joining_date >'2013-01-31'
EMPLOYEE
EMPLOYEE
EMPLOYEE
SQL Queries in MySQL, Select MICROSECOND(joining_date) from EMPLOYEE
incentives B on A.EMPLOYEE_ID=B.EMPLOYEE_REF_ID
39. Get names of employees from employee table who has '%' in Last_Name.
Tip : Escape character for special characters in a query.
SQL Queries in Oracle, Select FIRST_NAME from employee where Last_Name like
'%?%%'
SQL Queries in SQL Server, Select FIRST_NAME from employee where Last_Name
like '%[%]%'
SQL Queries in MySQL, Select FIRST_NAME from employee where Last_Name like
'%\%%'
40. Get Last Name from employee table after replacing special character with white
space
SQL Queries in SQL Server and MySQL, Select REPLACE(LAST_NAME,'%',' ') from
employee
department
42. Get department,total salary with respect to a department from employee table
order by total salary descending
44. Get department wise average salary from employee table order by salary
ascending
46. Get department wise minimum salary from employee table order by salary
ascending
47. Select no of employees joined with respect to year and month from
employee table
to_char (JOINING_DATE,'YYYY'),to_char(JOINING_DATE,'MM')
year(JOINING_DATE), month(JOINING_DATE)
49. Select employee details from employee table if data exists in incentive
table ?
50. How to fetch data that are common in two query results ?
select * from EMPLOYEE where EMPLOYEE_ID INTERSECT select * from
Explanation : Here "INTERSECT" command is used to fetch data that are common
in 2 queries. In this example, we had taken EMPLOYEE table in both the queries.We
can apply INTERSECT command on different tables. The result of the above query
will return employee details of "ROY" because, employee id of ROY is 3, and both
query results have the information about ROY.
51. Get Employee ID's of those employees who didn't receive incentives
without using sub query ?
select EMPLOYEE_ID from EMPLOYEE
MINUS
52. Select 20 % of salary from John , 10% of Salary for Roy and for other 15 %
of salary from employee table
SELECT FIRST_NAME, CASE FIRST_NAME WHEN 'John' THEN SALARY * .2 WHEN
'Roy' THEN SALARY * .10 ELSE SALARY * .15 END "Deduced_Amount" FROM
EMPLOYEE
Explanation : Here, we are using "SQL CASE" statement to achieve the desired
results. After case statement, we had to specify the column on which filtering is
applied. In our case it is "FIRST_NAME". And in then condition, specify the name of
filter like John, Roy etc. To handle conditions outside our filter, use else block where
every one other than John and Roy enters.
53. Select Banking as 'Bank Dept', Insurance as 'Insurance Dept' and Services
as 'Services Dept' from employee table
SQL Queries in SQL Server and MySQL, SELECT case DEPARTMENT when 'Banking'
then 'Bank Dept' when 'Insurance' then 'Insurance Dept' when 'Services' then 'Services
Explanation : Here "DECODE" keyword is used to specify the alias name. In oracle
we had specify, Column Name followed by Actual Name and Alias Name as
arguments. In SQL Server and MySQL, we can use the earlier switch case
statements for alias names.
54. Delete employee data from employee table who got incentives in incentive
table
INCENTIVES)
Explanation : Trick about this question is that we can't delete data from a table
based on some condition in another table by joining them. Here to delete multiple
entries from EMPLOYEE table, we need to use Subquery. Entries will get deleted
based on the result of Subquery.
55. Insert into employee table Last Name with " ' " (Single Quote - Special
Character)
Tip - Use another single quote before special character
56. Select Last Name from employee table which contain only numbers
Explanation : In order to achieve the desired result, we use "ASCII" property of the
database. If we get results for a column using Lower and Upper commands, ASCII of
both results will be same for numbers. If there is any alphabets in the column, results
will differ.
57. Write a query to rank employees based on their incentives for a month
FIRST_NAME='John' )
Explanation : We need to join Employee and Incentive Table for updating the
incentive amount. But for update statement joining query wont work. We need to use
sub query to update the data in the incentive table. SQL Query is as shown below.
59. Select first_name, incentive amount from employee and incentives table for
those employees who have incentives
Select FIRST_NAME,INCENTIVE_AMOUNT from employee a inner join incentives B
on A.EMPLOYEE_ID=B.EMPLOYEE_REF_ID
60. Select first_name, incentive amount from employee and incentives table for those
employees who have incentives and incentive amount greater than 3000
61. Select first_name, incentive amount from employee and incentives table for all
employes even if they didn't get incentives
A.EMPLOYEE_ID=B.EMPLOYEE_REF_ID
62. Select first_name, incentive amount from employee and incentives table for all
employees even if they didn't get incentives and set incentive amount as 0 for those
employees who didn't get incentives.
63. Select first_name, incentive amount from employee and incentives table for all
employees who got incentives using left join
64. Select max incentive with respect to employee from employee and incentives table
using sub query
SQL Queries in Oracle, select * from (select * from employee order by SALARY desc)
SQL Queries in SQL Server, select top 2 * from employee order by salary desc
SQL Queries in MySQL, select * from employee order by salary desc limit 2
SQL Queries in MySQL, select * from employee order by salary desc limit N
SQL Queries in Oracle, select min(salary) from (select * from (select * from employee
SQL Queries in SQL Server, select min(SALARY) from (select top 2 * from employee)
SQL Queries in MySQL, select min(SALARY) from (select * from employee order by
SQL Queries in Oracle, select min(salary) from (select * from (select * from employee
SQL Queries in SQL Server, select min(SALARY) from (select top N * from employee)
SQL Queries in MySQL, select min(SALARY) from (select * from employee order by
Both UNION and UNION ALL is used to select information from structurally similar
tables. That means corresponding columns specified in the union should have same
data type. For example, in the above query, if FIRST_NAME is DOUBLE and
LAST_NAME is STRING above query wont work. Since the data type of both the
columns are VARCHAR, union is made possible. Difference between UNION and
EMPLOYEE_ID NUMBER,
SALARY FLOAT(126),
KEY(EMPLOYEE_ID)
KEY(EMPLOYEE_ID,FIRST_NAME)
79. Write Sql syntax to create Oracle Trigger before insert of each row in
employee table
CREATE OR REPLACE TRIGGER EMPLOYEE_ROW_ID_TRIGGER
DECLARE
seq_no number(12);
BEGIN
END;
SHOW ERRORS;
REFRESH COMPLETE
NEXT SYSDATE + 1 AS
INCENTIVES b
where a.EMPLOYEE_ID=b.EMPLOYEE_REF_ID
BUILD IMMEDIATE
SQL Injection is one of the the techniques uses by hackers to hack a website by
https://www.tutorialspoint.com/sql_certificate/subqueries_to_solve_queries_questions.htm
A. Ordered sub-queries
B. Grouped sub-queries
C. Single row sub-queries
D. None of the above
A. SELECT
B. WHERE
C. ORDER BY
D. GROUP BY
Answer: A. A sub-query is just like any other query which has to start
with a SELECT clause. They are contained within an outer query.
A. By using JOINS
B. By using WHERE clause
C. By using the GROUP BY clause
D. By writing a SELECT statement embedded in the clause of another SELECT
statement
Answer: C.
A. HAVING
B. WHERE
C. FROM
D. All of the above
A. >=
B. <
C. =
D. All of the above
Answer: D. Single-row operators include =, >, <, >=, <=, and <>.
A. IN
B. ANY
C. ALL
D. All of the above
Answer: D. Multiple-row subqueries return more than one row of
results.Operators that can be used with multiple-row subqueries include
IN, ALL, ANY, and EXISTS.
11.You need to find the salaries for all the employees who have a
higher salary than the Vice President of a company 'ABC'.Which of
the following queries will give you the required result? (Consider
the table structure as given)
Answer: A. In the option 'A', the inner sub-query gives the VP's salary as
a result to the outer query.
Answer: A. Sub queries can be placed on left or right hand side of the
comparison operator depending on the query indentation and usability.
13. What will be the outcome of the following query? (Consider the
given table structure)
A. They can return more than one column as the result of the inner query
B. They return multiple rows in the main query but only a single result set in the
inner query
C. They return single row in the main query but multiple rows in the inner sub-
query
D. They return more than one row from the inner SELECT statement
Answer: C.
A. AND
B. <
C. >
D. <>
Answer: A. Single-row operators include =, >, <, >=, <=, and <>. Multi-
row operators that can be used with multiple-row subqueries include IN,
ALL, ANY, and EXISTS.
18.You need to find out the names of all employees who belong to
the same department as the employee 'Jessica Butcher' who is in
department 100 and has an employee ID 40. Which of the following
queries will be correct?
Answer: C. More than one sub-query can be written in one SQL statement
to add more than one condition.
20.Based on the answers for questions 18th and 19th, what type
of sub-queries is used by them?
Answer: A. The questions 18th and 19th given above demonstrate the
usage sub-queries in a SELECT statement.
i. The inner queries can get data from only one table
ii. The inner queries can get data from more than one table
Which of the above statements are true?
A. (i)
B. (ii)
C. Both (i) and (ii)
D. Neither (i) nor (ii)
Answer: B. Sub-queries can fetch data from more than one table.
A. It executes successfully and gives the employees who have salaries equal to
the max salary.
B. It executes successfully but does not give the required results
C. It throws an error as a group function is used in the sub-query
D. It throws an error as a single row sub-query should contain a multi-row
operator
A. It executes successfully and gives the names and minimum salary greater
than department 100 of all employees
B. It executes successfully and gives the salaries of the employees in
department 100
C. It executes successfully and gives the names and minimum salaries of all the
employees.
D. It throws an error.
Answer: A. HAVING clause can be used in sub-queries as shown
A. 1
B. NULL
C. 0
D. The query raises ORA error because sub-query is invalid.
A. 1
B. 14
C. 0
D. ORA error
28.Which of the following are valid multi row operators used for
sub-queries?
A. <=
B. ANY >=
C. !=
D. >=
A. TRUE
B. FALSE
C. NULL
D. 0
Answer: A. The multi row operators return Boolean results. As there are
results of salary in the department 100, it returns TRUE. If there are 0
results, it evaluates to FALSE.
Answer: D. If the department 100 has one result (single row sub-query),
the < ANY operator gives the error as it is a multi-row operator.
31.What will be the outcome of the query given above if the < ANY
operator is replaced with = ANY operator?
A. Oracle will treat each value of the salary returned from the sub-query as it
does with IN operator
B. There will be no difference in the results
C. The results will differ
D. The execution will thrown an ORA error
32.What can be said about the < ANY operator in the query given
above?
Answer: C. The multi row operator < ANY evaluates to the statements
"Less than the maximum" of the subquery. '> ALL' More than the highest
value returned by the subquery. '< ALL' Less than the lowest value
returned by the subquery. '< ANY' Less than the highest value returned
by the subquery. '< ANY' More than the lowest value returned by the
subquery. '= ANY' Equal to any value returned by the subquery (same as
IN). '[NOT] EXISTS' Row must match a value in the subquery
<
33.Assume that the < ANY operator is replaced with the > ANY.
What is true about this operator?
Answer: C. The multi row operator > ANY evaluates to the statements
"Greater than the minimum" of the subquery. '> ALL' More than the
highest value returned by the subquery. '< ALL' Less than the lowest value
returned by the subquery. '< ANY' Less than the highest value returned
by the subquery. '> ANY' More than the lowest value returned by the
subquery. '= ANY' Equal to any value returned by the subquery (same as
IN). '[NOT] EXISTS' Row must match a value in the subquery
<
34. Examine the given table structure and consider the following
query:
<
35. You need to find out which of the employees have a salary less
than that of the salary for the job ID 'FIN_ACT'. Which of the
following queries will give you the required output?
Answer: A. < ALL means less than the minimum. '> ALL' More than the
highest value returned by the subquery. '< ALL' Less than the lowest value
returned by the subquery. '< ANY' Less than the highest value returned
by the subquery. '> ANY' More than the lowest value returned by the
subquery. '= ANY' Equal to any value returned by the subquery (same as
IN). '[NOT] EXISTS' Row must match a value in the subquery
Answer: C. >ALL means less than the minimum. '> ALL' More than the
highest value returned by the subquery. '< ALL' Less than the lowest value
returned by the subquery. '< ANY' Less than the highest value returned
by the subquery. '> ANY' More than the lowest value returned by the
subquery. '= ANY' Equal to any value returned by the subquery (same as
IN). '[NOT] EXISTS' Row must match a value in the subquery
37.You need to find the salaries for all employees who are not in
the department 100. Which of the following queries will give you
the required result?
Answer: C. NOT can be used with the multi row operators IN, ANY and
ALL.
Examine the table structure as given. Consider the following query and
answer the questions 38 and 39 that follow. You need to find the
employees who do not have a sub-ordinate reporting to them. (Assume
there are 0 expected results)
A. 10
B. NULL
C. ORA error
D. 0
Answer: C.
A. SELECT department_name
B. FROM employees
C. WHERE department_id IN (SELECT distinct (department_id )
D. FROM employees);
E. SELECT department_name
F. FROM employees
G. WHERE department_id ANY (SELECT distinct (department_id )
H. FROM employees);
I. SELECT department_name
J. FROM employees
K. WHERE department_id < ANY (SELECT distinct (department_id )
L. FROM employees);
M. SELECT department_name
N. FROM employees
O. WHERE department_id = ANY (SELECT distinct (department_id )
P. FROM employees);
Answer: A, D.
A. 20
B. 50
C. Unlimited
D. 255
45. What should be the best practice to follow when we know what
values we need to pass on to the main query in Oracle queries?
A. Using GROUP BY
B. Using sub-queries
C. Using HAVING
D. None of the above
46.You need to find all the employees whose job ID is the same as
that of an employee with ID as 210. Which of the following WHERE
clauses would you add / modify to achieve this result? (Consider
the table structure as given
Answer: A.
WHERE job_id = (SELECT job_id FROM employees WHERE employee_id < 210);
You need to display the names of the employees who have the highest
salary. Which of the following SQL statements will be correct?
A. 255
B. 300
C. 216
D. Unlimited
A. The tables used in the main query are also used in a co-related sub-query
B. The sub-queries which reference a column used in the main query are called
co-related sub-queries
C. The sub-queries which are written without parenthesis are called co-related
sub-queries
D. The sub-queries which mandatorily use different tables than those used in the
main query are called co-related sub-queries
A. SELECT
B. GROUP BY
C. UPDATE
D. DELETE
Answer: B. The rest of the options can be in the main query (parent
query) of a sub-query.
A. SELECT *
B. FROM employees E
C. WHERE exists (SELECT 1 FROM employees E1
D. WHERE E.employee_id = E1.employee_id);
E. SELECT *
F. FROM employees E
G. WHERE exists (SELECT 1 FROM employees E1
H. WHERE E.employee_id = E1.employee_id
I. AND E.ROWID < E1.ROWID);
J. SELECT *
K. FROM employees E
L. WHERE exists (SELECT 1 FROM employees E1
M. WHERE E.ROWID < E1.ROWID);
N. SELECT *
O. FROM employees E
P. WHERE = ANY (SELECT 1 FROM employees E1
Q. WHERE E.employee_id = E1.employee_id
R. And E.ROWID < E1.ROWID);
56.Which of the following queries will display the system date and
count of records in the DEPARTMENTS and EMPLOYEES table?
A. SELECT sysdate,
B. (SELECT * FROM departments) dept_count,
C. (SELECT * FROM employees) emp_count
D. FROM DUAL;
E. SELECT sysdate,
F. (SELECT count(*) FROM departments) dept_count,
G. (SELECT count(*) FROM employees) emp_count
H. FROM DUAL
I. GROUP BY department_id ;
J. SELECT sysdate,
K. (SELECT * FROM departments) dept_count,
L. (SELECT * FROM employees) emp_count
M. FROM DUAL
N. GROUP BY employee_id;
O. SELECT sysdate,
P. (SELECT count(*) FROM departments) dept_count,
Q. (SELECT count(*) FROM employees) emp_count
R. FROM DUAL;
Answer: C.
Consider the following query and answer the questions that 59 to 62 that
follow.
SELECT department_name
FROM departments d INNER JOIN employees e
ON (d.employee_id = e.employee_id)
GROUP BY department_name;
A. SELECT department_name
B. FROM departments
C. WHERE department_id = ANY (SELECT department_id FROM employees);
D. SELECT department_name
E. FROM departments
F. WHERE department_id IN (SELECT distinct(department_id ) FROM employees);
G. SELECT department_name
H. FROM departments
I. WHERE department_id = (SELECT distinct(department_id ) FROM employees);
J. SELECT department_name
K. FROM departments
L. WHERE department_id ANY (SELECT distinct(department_id ) FROM employees);
Answer: A, B.
What will be the outcome as a result of this change? (Choose the most
appropriate answer)
A. It will order the department_id fetched from the sub-query and display them
in ascending order
B. It will throw an ORA error as the ORDER BY clause should be accompanied by
the GROUP BY clause
C. It will throw an ORA error because an ORDER BY clause cannot be used inside
a sub-query
D. It will execute successfully.
SELECT department_name
FROM departments
WHERE department_id = ANY (SELECT department_id FROM employees)
ORDER BY department_id desc;
What will be the outcome as a result of this change? (Choose the most
appropriate answer)
A. It will order the department_id fetched from the sub-query and display them
in ascending order
B. It will order the department_id fetched from the sub-query and display them
in descending order
C. It will throw an ORA error because an ORDER BY clause cannot be used inside
a sub-query
D. None of the above
A. ORDER BY
B. HAVING
C. GROUP BY
D. All of the above
A. It gives all AU_ID and AU_TITLEs starting with the letter 'S%'
B. It gives all AU_ID and AU_TITLEs starting with the letter 'S%' ordered by the
titles in ascending order
C. It throws an ORA error
D. It returns a 0 value
SELECT *
FROM employees
WHERE salary BETWEEN (SELECT max(salary)
FROM employees
WHERE department_id = 100)
AND (SELECT min(salary) FROM employees where department_id = 100);
This query returns an error. What is the reason for the error?
65.What is true about using NOT IN when writing queries with sub-
queries in them?
A. NOT IN ignores all the NULL values and gives only the NOT NULL values
B. NOT IN puts all the NULL values at the last and gives the NOT NULL to be
displayed first
C. NOT IN should be not be used if a NULL value is expected in the result set
D. NOT IN is just a negation of the operator IN and can be changed without any
caveat.
66. You need to find out the names and IDs of the departments in
which the least salary is greater than the highest salary in the
department 10. Which of the following queries will give the
required result.
Answer: A.
Answer: A, B.
68.You need to find out all the employees who have salary greater
than at least one employee in the department 10. Which of the
following queries will give you the required output?
Answer: B.
69.You need to find out all the employees who have salary lesser
than the salary of all the employees in the department 10. Which
of the following queries will give you the required output?
Answer: C.
72.You need to find the highest earning employee with the job ID
as 'SA_REP'. Which of the following queries will be correct?
(Choose the most appropriate answer)
Answer: B.
73.You need to find the job which has at least one employee in it.
Which of the following queries will be correct? (Choose the most
appropriate answer)
74.You need to find the job which has no employees in it. Which of
the following queries will be correct? (Choose the most
appropriate answer)
A. SELECT employee_id, Job_id
B. FROM employees E
C. WHERE exists
D. (
E. SELECT *
F. FROM employees E1
G. WHERE E.job_id = E1.job_id )
H. SELECT employee_id, Job_id
I. FROM employees E
J. WHERE not exists
K. (
L. SELECT 1
M. FROM employees E1
N. WHERE E.job_id = E1.job_id )
O. SELECT employee_id, Job_id
P. FROM employees E
Q. WHERE not exists
R. (
S. SELECT *
T. FROM employees E1
U. WHERE E.job_id = E1.job_id )
V. SELECT employee_id, Job_id
W. FROM employees E
X. WHERE exists
Y. (
Z. SELECT 1
AA. FROM employees E1
BB. WHERE E.job_id < E1.job_id )
75.You need to find the 3rd maximum salary from the EMPLOYEES
table. Which of the following queries will give you the required
results? (Choose the most appropriate answer)
A. SELECT *
B. FROM employees E
C. WHERE salary = (SELECT count(distinct salary )
D. FROM employees
E. WHERE e.salary = salary
F. );
G. SELECT *
H. FROM employees E
I. WHERE 1 = (SELECT count(distinct salary )
J. FROM employees
K. WHERE e.salary < salary
L. );
M. SELECT *
N. FROM employees E
O. WHERE 2 = (SELECT count(distinct salary )
P. FROM employees
Q. WHERE e.salary >salary
R. );
S. SELECT *
T. FROM employees E
U. WHERE 3 = (SELECT count(distinct salary )
V. FROM employees
W. WHERE e.salary <= salary
X. );
Answer: D.
76. You need to find the maximum salary by using the user input
for getting the value of N. Which of the following queries will give
you the required results? (Choose the most appropriate answer)
Answer: C. ROWNUM is a pseudo column used for finding the nth order
results.
Answer: D.
A. 255
B. 100
C. 2
D. 16
Answer: A.
Answer: B.
Answer: C.
Answer: C. '> ALL' More than the highest value returned by the subquery.
'< ALL' Less than the lowest value returned by the subquery. '< ANY' Less
than the highest value returned by the subquery. '> ANY' More than the
lowest value returned by the subquery. '= ANY' Equal to any value
returned by the subquery (same as IN). '[NOT] EXISTS' Row must match
a value in the subquery.
Answer: C.
83.You need to find the details of all employees who were hired for
the job ID 'SA_REP' in the month of June, 2013. Which of the
following queries will give the required results? (Consider the
table structure as given)
A. SELECT first_name
B. FROM employees
C. WHERE employee_id =
D. ( SELECT employee_id
E. FROM employees
F. WHERE to_char(hiredate, 'MM/YYYY')= '02/1981'
G. AND job_id = 'SA_REP'
H. );
I. SELECT first_name
J. FROM employees
K. WHERE employee_id = ANY
L. ( SELECT employee_id
M. FROM employees
N. WHERE to_char(hiredate, 'MM/YYYY')= '02/1981'
O. AND job_id = 'SA_REP'
P. );
Q. SELECT first_name
R. FROM employees
S. WHERE employee_id ANY
T. ( SELECT employee_id
U. FROM employees
V. WHERE to_char(hiredate, 'MM/YYYY')= '02/1981'
W. AND job_id = 'SA_REP'
X. );
Y. SELECT first_name
Z. FROM employees
AA. WHERE employee_id exists
BB. ( SELECT employee_id
CC. FROM employees
DD. WHERE to_char(hiredate, 'MM/YYYY')= '02/1981'
EE. AND job_id = 'SA_REP'
FF. );
Answer: B.
Answer: A, B.
Query 1:
SELECT first_name
FROM employees e join departments d
ON e.department_id = d.department_id
WHERE department_name='ACCOUNTS';
Query 2:
SELECT first_name
FROM employees e
WHERE department_id = ANY (SELECT department_id FROM departments d
WHERE department_name='ACCOUNTS');
Answer: A, D.
86.You need to display all the employees who have the highest
salary in a department 100. You fire a query as below.
SELECT E.first_name, E.last_name , E.salary
FROM employees E
WHERE E.salary > ALL (SELECT E1.salary
FROM employees E1
WHERE E.department_id =E1.department_id
AND E.department_id = 100);
Answer: B, D. >ALL will not give the required result as there may be two
employees with the same salary and who are the highest earners in the
department 100
Answer: C.
88.In the queries given above (option C is the correct answer), you
need to display all the employees with the JOB ID 'SA_REP' who
have the maximum salary in the department 100. Which of the
following queries will give the required output?
89.Select the query which will give you the maximum salary and
maximum comm percentage. The query should also give the
maximum comm percentage paid if the highest salaried employee
gets the maximum comm percentage.
A. These sub-queries are the same in all aspects as those used in the FROM or
WHERE clauses
B. These sub-queries have to mandatorily be single row sub-queries
C. We can use multi row operators when writing such sub-queries
D. None of the above
Answer: B.
A. It gives the system date and the maximum salary for each department
B. It gives the maximum salary for all the departments
C. It throws an ORA error
D. It executes successfully with 0 rows
A. SELECT salary
B. FROM employees
C. WHERE salary >10 or salary > 20 and salary >30;
D. SELECT salary
E. FROM employees
F. WHERE salary <10 and salary < 20 and salary <30;
G. SELECT salary
H. FROM employees
I. WHERE salary >10 and salary > 20 and salary >30;
J. SELECT salary
K. FROM employees
L. WHERE salary >10 and salary > 20 or salary < 30;
A. SELECT E.salary
B. FROM employees E
C. WHERE E.salary > (SELECT E1.salary
D. FROM employees E1
E. WHERE E1.department_id = 100);
F. SELECT E.salary
G. FROM employees E
H. WHERE E.salary >ALL (SELECT E1.salary
I. FROM employees E1
J. WHERE E1.department_id = 100);
K. SELECT E.salary
L. FROM employees E
M. WHERE E.salary = (SELECT E1.salary
N. FROM employees E1
O. WHERE E1.department_id = 100);
P. SELECT E.salary
Q. FROM employees E
R. WHERE E.salary >= (SELECT E1.salary
S. FROM employees E1
T. WHERE E1.department_id = 100);
A. SELECT E.salary
B. FROM employees E
C. WHERE NOT EXISTS (E.salary =ANY (SELECT E1.salary
D. FROM employees E1
E. WHERE E1.department_id = 100);
F. SELECT E.salary
G. FROM employees E
H. WHERE E.salary >ANY (SELECT E1.salary
I. FROM employees E1
J. WHERE E1.department_id = 100);
K. SELECT E.salary
L. FROM employees E
M. WHERE E.salary =ANY (SELECT E1.salary
N. FROM employees E1
O. WHERE E1.department_id = 100);
P. SELECT E.salary
Q. FROM employees E
R. WHERE NOT ( E.salary <= ANY (SELECT E1.salary
S. FROM employees E1
T. WHERE E1.department_id = 100));
Answer: D. The NOT operator used while using '<= ANY' is used for
negation of the results returned by the sub-query
A. SELECT E.salary
B. FROM employees E
C. WHERE NOT EXISTS (E.salary = ANY (SELECT E1.salary
D. FROM employees E1
E. WHERE E1.department_id = 100);
F. SELECT E.salary
G. FROM employees E
H. WHERE NOT EXISTS (SELECT E1.salary
I. FROM employees E1
J. WHERE E1.department_id = 100
K. And E.salary <= E1.salary);
L. Either A or B
M. None of the above
A. SELECT salary
B. FROM employees
C. WHERE salary >10 or salary > 20 and or >30;
D. SELECT salary
E. FROM employees
F. WHERE salary <10 and salary < 20 and salary <30;
G. SELECT salary
H. FROM employees
I. WHERE salary >10 and salary > 20 or salary >30;
J. SELECT salary
K. FROM employees
L. WHERE salary >10 and salary > 20 or salary < 30;
A. SELECT E.salary
B. FROM employees E
C. WHERE E.salary > (SELECT E1.salary
D. FROM employees E1
E. WHERE E1.department_id = 100);
F. SELECT E.salary
G. FROM employees E
H. WHERE E.salary >ANY (SELECT E1.salary
I. FROM employees E1
J. WHERE E1.department_id = 100);
K. SELECT E.salary
L. FROM employees E
M. WHERE E.salary = (SELECT E1.salary
N. FROM employees E1
O. WHERE E1.department_id = 100);
P. SELECT E.salary
Q. FROM employees E
R. WHERE E.salary >= (SELECT E1.salary
S. FROM employees E1
T. WHERE E1.department_id = 100);
A. SELECT E.salary
B. FROM employees E
C. WHERE NOT EXISTS (E.salary =ANY (SELECT E1.salary
D. FROM employees E1
E. WHERE E1.department_id = 100);
F. SELECT E.salary
G. FROM employees E
H. WHERE EXISTS (SELECT E1.salary
I. FROM employees E1
J. WHERE E1.department_id = 100
K. And E.salary >E1.salary);
L. SELECT E.salary
M. FROM employees E
N. WHERE EXISTS (SELECT E1.salary
O. FROM employees E1
P. WHERE E1.department_id = 100
Q. );
R. SELECT E.salary
S. FROM employees E
T. WHERE IN (SELECT E1.salary
U. FROM employees E1
V. WHERE E1.department_id = 100);
99.Examine the given table structure. How many rows will get
generated if the sub-query mentioned returns 0 rows?
A. 1 row
B. No rows
C. Either A or B
D. None of the above
Answer: B. If the sub-query returns zero rows, the '> ANY' condition
evaluates to FALSE, hence "No rows" are returned.
A. The inner query needs to reference the value returned to the outer query.
B. The value returned by the inner query is to be compared to grouped data in
the outer query.
C. The subquery returns more than one value to the outer query.
D. None of the above. Subqueries can't be used in the outer query's HAVING
clause.
Following table lists out the pros and cons of Agile Model:
Pros Cons
Easy to manage