0% found this document useful (0 votes)
544 views5 pages

DB Questions

This document contains 20 multiple choice questions about SQL concepts like single row functions, subqueries, joins, aggregation functions and wildcards. The questions cover topics like valid placements of subqueries, uses of wildcards, comparison operators that can be used with multiple row queries, and properties of functions like COALESCE, MAX, MIN. The answers provided are also in multiple choice format with one option being the correct answer in each case.

Uploaded by

Neeraj Tripathy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
544 views5 pages

DB Questions

This document contains 20 multiple choice questions about SQL concepts like single row functions, subqueries, joins, aggregation functions and wildcards. The questions cover topics like valid placements of subqueries, uses of wildcards, comparison operators that can be used with multiple row queries, and properties of functions like COALESCE, MAX, MIN. The answers provided are also in multiple choice format with one option being the correct answer in each case.

Uploaded by

Neeraj Tripathy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

Q 1 - Which of the following is not true about single row functions?

A - They operate on single rows only and return one result per row.
B - They accept arguments that could be a column or any expression.
C - They cannot be nested.
D - They may modify the data type.
Answer : C
Q2- A subquery can be placed in which of the SQL clauses?
A - The WHERE clause
B - The HAVING clause
C - The FROM clause
D - All of the above.
Answer : D
q3-The
A.
B.
C.
D.

wildcard in a WHERE clause is useful when?


An exact match is necessary in a SELECT statement.
An exact match is not possible in a SELECT statement.
An exact match is necessary in a CREATE statement.
An exact match is not possible in a CREATE statement.

Answer: Option B
q4. The || is is an example of what function SELECT last_name||','||first_name||
' '||middle_name from employee;
A.Incantination
b.integration
c.Continuation
D.Concatenation
E.None of the above
Ans D
Q5.You want all dates when any employee was hired. Multiple employees were hired
on the same date and you want to see the date only once.
query-1 Select distinct hiredate from hr.employee order by hiredate;
Query-2 Select hiredate from hr.employee group by hireddate order by hiredate;
Which of the above query is valid?
A)Query-1
B)Query-2
C)Both
Ans:Cs except for
q6.All aggregate functions ignore NULLs excepts for....
A)Distinct
B)Count(*)
c)Average()
D)None of Above
Ans:D

Q7.For the purpose of ........ null values are considered equal to other nulls a
re grouped together into a single result row.
a)Having
b)Group By
c)Both of above
D)None of above
Ans:B
Q8. Which of the following comparison operators could be used in a multiple row
query?
A - IN operator
B - ANY operator
C - ALL operator
D - All of the above
Answer : D
q9.Consider the following schema STUDENTS(student_code, first_name, last_name, email,
phone_no, date_of_birth, honours_subject, percentage_of_marks);
Which of the following code will create a simple view named all_marks_english th
at contains the names and percentage of marks of the students in the honours_sub
ject Eng01 ?
A - create view all_marks_english as select first_name, last_name, percentage_of
_marks from students where honours_subject = Eng01 ;
B - create view all_marks_english as ( first_name, last_name, percentage_of_mark
s from students where honours_subject = Eng01 );
C - select view all_marks_english as select first_name, last_name, percentage_of
_marks from students where honours_subject = Eng01 ;
D - None of the above.
Ans:A
q10 - Consider the following schema STUDENTS(student_code, first_name, last_name, email,
phone_no, date_of_birth, honours_subject, percentage_of_marks);
Which of the following query would display the full name of a student, with a co
lumn heading "Name"
A - select first_name, last_name as

Name from students;

B - select Name from students;


C - select first_name || last_name as

Name from students;

D - select first_name, last_name from students;

Answer : C
Q11- Which of the following is not true about the COALESCE function?
A - It takes multiple alternate values.
B - It returns the first non-null expression in the parameter list.
C - It returns the first value in the parameter list if it is null.
D - None of the above.
Show Answer
Answer : C
q12.Which of the following is not true about the MAX and MIN functions?
A - Both can be used for any data type.
B - MAX returns the maximum value.
C - MIN returns the minimum value.
D - All are true.
Show Answer
Answer : D
q13.Which of the following is true about subqueries?
A - Subqueries could be used for Top-N analysis.
B - Subqueries can be of two types
.

single-row subquery and multiple-row subquery

C - The outer and inner queries can get data from different tables.
D - All of the above.
Answer : D
q-14. Which of the following is not true about multiple-row subqueries?
A - Multiple row subqueries return multiple rows from the outer SELECT statement
.
B - Multiple row subqueries return multiple rows from the inner SELECT statement
.
C - Multiple row subqueries use multiple-row comparison operators.
D - All of the above.
Answer : B
q-15.Consider the following schema -

STUDENTS(student_code, first_name, last_name, email,


phone_no, date_of_birth, honours_subject, percentage_of_marks);
Which of the following query would display names of all the students whose honou
rs subject is English and percentage of marks more than 80, or honours subject i
s Spanish and percentage of marks more than 80?
A - select first_name, last name from students where (honours_subject =
honours_subject = Spanish ) and percentage_of_marks > 80;
B - select first_name, last name from students where honours_subject =
honours_subject = Spanish and percentage_of_marks > 80;

English
English

or
or

C - select first_name, last name from students where (honours_subject =


honours_subject = Spanish and percentage_of_marks > 80);

English

D - select first_name, last name from students where (honours_subject =


r honours_subject = Spanish and percentage_of_marks > 80;

English ) o

Answer : A
q-16 - Which of the following query will result in an error?
A - select dept_id, avg(salary) from employees group by dept_id;
B - select avg(salary) from employees group by dept_id;
C - select dept_id, job_id, avg(salary) from employees group by dept_id, job_id;
D - select dept_id, count(name) from employees;
Answer : D
q-17 Consider the following schema STUDENTS(student_code, first_name, last_name, email,
phone_no, date_of_birth, honours_subject, percentage_of_marks);
Which of the following query would display names of all the students whose email
ids are not provided?
A - select first_name, last name from students where email = 0;
B - select first_name, last name from students where email =

C - select first_name, last name from students where email is null;


D - select first_name, last name from students where email = null ;
Answer : C
q-18 Consider the following schema HONOURS_SUBJECT(subject_code, subject_name, department_head);
LOCATIONS(subject_code, department_name, location_id, city);
Select the right query for retrieving records from the tables HONOURS_SUBJECT an
d LOCATIONS with a left outer join
A - select h.subject_name, l.department_name, h.department_head, l.city from hon
ours_subject h left outer join location l on(h.subject_code = l.subject_code);

or

B - select h.subject_name, l.department_name, h.department_head, l.city from hon


ours_subject h left outer join location l on(subject_code);
C - select h.subject_name, l.department_name, h.department_head, l.city from hon
ours_subject h left join location l on(h.subject_code = l.subject_code);
D - None of the above.
Answer : A
q-19
The result of a SQL SELECT statement is a(n) ________ .
A.
report
B.
form
C.
file
D.
table
Answer: Option D
q-20
The SQL
A.
B.
C.
D.

-92 wildcards are ____ and ____ .


asterisk (*); percent sign (%)
percent sign (%); underscore (_)
underscore(_); question mark (?)
question mark (?); asterisk (*)

Answer: Option B

You might also like