SQL Mock Test


Advertisements


This section presents you various set of Mock Tests related to SQL. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Questions and Answers

SQL Mock Test I

Q 2 - 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 column 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

Q 3 - 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 distinct honours subjects in the STUDENTS table?

A - select honours_subject from students;

B - select distinct honours_subject from students;

C - select all honours_subject from students;

D - select * from students;

Answer : B

Q 4 - 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 all the students with honours_subject ‘Eng01’?

A - select student_code, first_name, last_name from students where honours_subject = ‘Eng01’;

B - select student_code, first_name, last_name from students where honours_subject is ‘Eng01’;

C - select student_code, first_name, last_name where honours_subject = ‘Eng01’

    from students;

D - select student_code, first_name, last_name from students;

Answer : A

Q 5 - 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 all the students whose first name starts with the character ‘A’?

A - select first_name from students where first_name like ‘A%’;

B - select first_name from students where first_name like ‘%A’;

C - select first_name from students where first_name like ‘%A%’;

D - select first_name from students where first_name like ‘A’;

Answer : A

Q 6 - 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 all the students where the second letter in the first name is ‘i’?

A - select first_name from students where first_name like ‘_i%’;

B - select first_name from students where first_name like ‘%i_’;

C - select first_name from students where first_name like ‘%i%’;

D - select first_name from students where first_name like ‘_i_’;

Answer : A

Q 7 - 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

Answer : C

Q 11 - 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 and percentage of marks of all students sorted by honours subject, and then order by percentage of marks?

A - select first_name, last name, honours_subject, percentage_of_marks from students order by honours_subject, percentage_of_marks;

B - select first_name, last name, honours_subject, percentage_of_marks order by percentage_of_marks desc from students;

C - select first_name, last name, percentage_of_marks from students order by percentage_of_marks desc;

D - select first_name, last name, percentage_of_marks from students order by percentage_of_marks, honours_subject;

Answer : A

Q 14 - Which of the following is not a character manipulation function?

A - concat

B - substr

C - instr

D - coalesce

Answer : D

Q 15 - What is returned by INSTR(‘TUTORIALS POINT’, ‘P’)?

A - 11

B - 10

C - POINT

D - TUTORIALS

Answer : A

Q 16 - What is returned by SUBSTR(‘TUTORIALS POINT’, 1, 9)?

A - TUTORIAL

B - POINT

C - TUTORIALS

D - UTORIALS

Answer : C

Q 17 - What is returned by SUBSTR(‘TUTORIALS POINT’, -1, 1)?

A - T

B - NULL

C - 0

D - N

Answer : A

Q 18 - What is returned by ROUND(789.8389, 2)?

A - 789.84

B - 789.83

C - 78

D - 789.00

Answer : A

Q 19 - What is returned by TRUNC(789.8389, 2)?

A - 789.84

B - 789.83

C - 78

D - 789.00

Answer : B

Q 20 - What is returned by MOD(1000,30)?

A - 33

B - 30

C - 3

D - 10

Answer : D

Q 21 - Consider the following schema −

STUDENTS(student_code, first_name, last_name, email, 
         phone_no, date_of_birth, honours_subject, percentage_of_marks);

Which query will display the names and honours subjects of all students and if a student has not yet been given a honours subject yet, then it should display ‘No Honours Yet’.

A - select first_name, last name, nvl(honours_subject, ‘No Honours Yet’) from students;

B - select first_name, last name, nvl2(honours_subject, ‘No Honours Yet’) from students;

C - select first_name, last name, honours_subject, from students;

D - select first_name, last name, nullif(honours_subject, ‘No Honours Yet’) from students;

Answer : A

Q 22 - You want to calculate the tax payable by the employees of an organization. If the employee gets a commission, then the tax would be calculated on commission plus salary, if the employee does not get any commission, then the tax would be calculated on salary only. Which function should you use for calculating tax?

A - NVL

B - NVL2

C - NULLIF

D - COALESCE

Answer : B

Q 23 - For some particular assignment, you need to compare two values, if both are equal, the result would be null, and if the values are not equal then the first value should be returned. Which function should you use?

A - NVL

B - NVL2

C - NULLIF

D - COALESCE

Answer : C

Answer Sheet

Question Number Answer Key
1 D
2 C
3 B
4 A
5 A
6 A
7 C
8 A
9 B
10 C
11 A
12 D
13 C
14 D
15 A
16 C
17 A
18 A
19 B
20 D
21 A
22 B
23 C
24 C
25 A

sql_questions_answers.htm


Advertisements
E-Books Store