SQL Mock Quiz 1 Questions
SQL Mock Quiz 1 Questions
Dashboard / My courses / Term I [2021-22] / T1-21-22-CS301P / Topic 1 / Mock SQL Exam (Not for grading)
Question 1
Not yet answered
Find the total number of project hours for the Research department arrange result set by project number.
sample output:
+------------+-----+
| sum(hours) | pno |
+------------+-----+
| 53 | 1 |
| 38 | 2 |
| 50 | 3 |
+------------+-----+
3 rows in set (0.00 sec)
Answer:
Question 2
Not yet answered
sample output:
+------+
| age |
+------+
| 49 |
| 52 |
| 53 |
| 56 |
| 59 |
| 66 |
| 80 |
| 84 |
+------+
8 rows in set (0.00 sec)
Answer:
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384 1/2
11/26/21, 3:50 PM Mock SQL Exam (Not for grading) (page 1 of 9)
Question 3
Select ssn of employees whose average project hours is at least 10 hours and sort the results by ssn.
sample output:
+-----------+
| essn |
+-----------+
| 123456789 |
| 123456789 |
| 333445555 |
| 333445555 |
| 453453453 |
| 453453453 |
| 666884444 |
+-----------+
Answer:
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384 2/2
11/26/21, 3:50 PM Mock SQL Exam (Not for grading) (page 2 of 9)
Dashboard / My courses / Term I [2021-22] / T1-21-22-CS301P / Topic 1 / Mock SQL Exam (Not for grading)
Question 4
Not yet answered
sample output:
+----------+
| fname |
+----------+
| Franklin |
| Jennifer |
| Ramesh |
+----------+
3 rows in set (0.00 sec)
Answer:
Question 5
Not yet answered
Select Employees with having letter 's' in their First name arrange results set by the first name.
sample output:
+--------+-------+---------+-----------+------------+--------------------------+------+--------+-----------+------+
| Fname | Minit | Lname | SSN | Bdate | Address | Sex | Salary | Super_ssn | Dno |
+--------+-------+---------+-----------+------------+--------------------------+------+--------+-----------+------+
+--------+-------+---------+-----------+------------+--------------------------+------+--------+-----------+------+
Answer:
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384&page=1 1/2
11/26/21, 3:50 PM Mock SQL Exam (Not for grading) (page 2 of 9)
Question 6
Find employees having a salary of at least 25000 and arrange the resultset by the last name.
sample output :
+----------+-------+---------+-----------+------------+---------------------------+------+--------+-----------+------+
| Fname | Minit | Lname | SSN | Bdate | Address | Sex | Salary | Super_ssn | Dno |
+----------+-------+---------+-----------+------------+---------------------------+------+--------+-----------+------+
| James |E | Borg | 888665555 | 1937-01-09 | 450 Fondren, Houston, TX | M | 55000 | NULL | 1|
+----------+-------+---------+-----------+------------+---------------------------+------+--------+-----------+------+
8 rows in set (0.00 sec)
Answer:
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384&page=1 2/2
11/26/21, 3:50 PM Mock SQL Exam (Not for grading) (page 3 of 9)
Dashboard / My courses / Term I [2021-22] / T1-21-22-CS301P / Topic 1 / Mock SQL Exam (Not for grading)
Question 7
Not yet answered
sample output:
+-----------+
| plocation |
+-----------+
| Bellaire |
| Houston |
| Stafford |
| Sugarland |
+-----------+
Answer:
Question 8
Not yet answered
Find the male employees who were born after 1950, arrange the resultset salary.
sample output:
+----------+-------+---------+-----------+------------+--------------------------+------+--------+-----------+------+
| Fname | Minit | Lname | SSN | Bdate | Address | Sex | Salary | Super_ssn | Dno |
+----------+-------+---------+-----------+------------+--------------------------+------+--------+-----------+------+
+----------+-------+---------+-----------+------------+--------------------------+------+--------+-----------+------+
4 rows in set (0.00 sec)
Answer:
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384&page=2 1/2
11/26/21, 3:50 PM Mock SQL Exam (Not for grading) (page 3 of 9)
Question 9
Find employees having no manager or having salaries less than 30000 arrange resultset by the youngest employee to the oldest.
sample output:
+--------+-------+---------+-----------+------------+---------------------------+------+--------+-----------+------+
| Fname | Minit | Lname | SSN | Bdate | Address | Sex | Salary | Super_ssn | Dno |
+--------+-------+---------+-----------+------------+---------------------------+------+--------+-----------+------+
| Joyce | A | English | 453453453 | 1972-01-09 | 5631 Fondren, Houston, TX | F | 25000 | 333445555 | 5|
+--------+-------+---------+-----------+------------+---------------------------+------+--------+-----------+------+
3 rows in set (0.00 sec)
Answer:
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384&page=2 2/2
11/26/21, 3:51 PM Mock SQL Exam (Not for grading) (page 4 of 9)
Dashboard / My courses / Term I [2021-22] / T1-21-22-CS301P / Topic 1 / Mock SQL Exam (Not for grading)
Question 10
Not yet answered
Find all the female employees having salary within the range of 30000 and 50000 arrange result by department number. (without using
operators like <,>)
sample output:
+----------+-------+---------+-----------+------------+-------------------------+------+--------+-----------+------+
| Fname | Minit | Lname | SSN | Bdate | Address | Sex | Salary | Super_ssn | Dno |
+----------+-------+---------+-----------+------------+-------------------------+------+--------+-----------+------+
| Jennifer | S | Wallace | 987654321 | 1941-01-09 | 21 Fondren, Houston, TX | F | 43000 | 888665555 | 4|
+----------+-------+---------+-----------+------------+-------------------------+------+--------+-----------+------+
1 row in set (0.00 sec)
Answer:
Question 11
Not yet answered
Find employees not having any dependents arrange results by the first name.
sample output:
+--------+-------+---------+-----------+------------+---------------------------+------+--------+-----------+------+
| Fname | Minit | Lname | SSN | Bdate | Address | Sex | Salary | Super_ssn | Dno |
+--------+-------+---------+-----------+------------+---------------------------+------+--------+-----------+------+
+--------+-------+---------+-----------+------------+---------------------------+------+--------+-----------+------+
5 rows in set (0.00 sec)
Answer:
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384&page=3 1/2
11/26/21, 3:51 PM Mock SQL Exam (Not for grading) (page 4 of 9)
Question 12
+-------------+
| min(salary) |
+-------------+
| 25000 |
+-------------+
Answer:
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384&page=3 2/2
11/26/21, 3:51 PM Mock SQL Exam (Not for grading) (page 5 of 9)
Dashboard / My courses / Term I [2021-22] / T1-21-22-CS301P / Topic 1 / Mock SQL Exam (Not for grading)
Question 13
Not yet answered
Display first name of all employees. Use 'First' as the column alias.Arrange result set by first name.
+----------+
| First |
+----------+
| Ahmad |
| Alicia |
| Franklin |
| James |
| Jennifer |
| John |
| Joyce |
| Ramesh |
+----------+
8 rows in set (0.00 sec)
Answer:
Question 14
Not yet answered
Show the sum of salaries of all the male employees and all the female employees ordered by sex.
+------+-------------+
| sex | sum(salary) |
+------+-------------+
|F | 136000 |
|M | 150000 |
+------+-------------+
Answer:
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384&page=4 1/2
11/26/21, 3:51 PM Mock SQL Exam (Not for grading) (page 5 of 9)
Question 15
+----------+
| count(*) |
+----------+
| 4|
+----------+
Answer:
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384&page=4 2/2
11/26/21, 3:51 PM Mock SQL Exam (Not for grading) (page 6 of 9)
Dashboard / My courses / Term I [2021-22] / T1-21-22-CS301P / Topic 1 / Mock SQL Exam (Not for grading)
Question 16
Not yet answered
Show the ssn and maximum number of hours worked on a project for given employees order by ssn.
+-----------+------------+
| essn | max(hours) |
+-----------+------------+
| 123456789 | 32.5 |
| 333445555 | 10 |
| 453453453 | 20 |
| 666884444 | 40 |
| 888665555 | NULL |
| 987654321 | 20 |
| 987987987 | 35 |
| 999887777 | 30 |
+-----------+------------+
Answer:
Question 17
+-------------+
| min(salary) |
+-------------+
| 25000 |
+-------------+
Answer:
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384&page=5 1/2
11/26/21, 3:51 PM Mock SQL Exam (Not for grading) (page 6 of 9)
Question 18
+--------------------+
| avg(hours) |
+--------------------+
| 18.333333333333332 |
+--------------------+
Answer:
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384&page=5 2/2
11/26/21, 3:51 PM Mock SQL Exam (Not for grading) (page 7 of 9)
Dashboard / My courses / Term I [2021-22] / T1-21-22-CS301P / Topic 1 / Mock SQL Exam (Not for grading)
Question 19
Not yet answered
Show the department id and count of employees in each department who have a salary > 30000 order by dno.
+------+------------+
| dno | count(ssn) |
+------+------------+
| 1| 1|
| 4| 1|
| 5| 2|
+------+------------+
Answer:
Question 20
Not yet answered
Show the ssn of employees who have more than 1 dependent order by ssn
+-----------+
| essn |
+-----------+
| 123456789 |
| 333445555 |
+-----------+
Answer:
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384&page=6 1/2
11/26/21, 3:51 PM Mock SQL Exam (Not for grading) (page 7 of 9)
Question 21
Show the ssn and number of projects worked on by each employee for employees working on more than one project order by ssn
+-----------+------------+
| essn | count(pno) |
+-----------+------------+
| 123456789 | 2|
| 333445555 | 4|
| 453453453 | 2|
| 987654321 | 2|
| 987987987 | 2|
| 999887777 | 2|
+-----------+------------+
Answer:
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384&page=6 2/2
11/26/21, 3:51 PM Mock SQL Exam (Not for grading) (page 8 of 9)
Dashboard / My courses / Term I [2021-22] / T1-21-22-CS301P / Topic 1 / Mock SQL Exam (Not for grading)
Question 22
Not yet answered
Show ssn,first name and department name they belong to for all employees order by ssn
+-----------+----------+----------------+
| ssn | fname | dname |
+-----------+----------+----------------+
| 123456789 | John | Research |
+-----------+----------+----------------+
Answer:
Question 23
Show ssn and first name of all employees whose departments are based at Houston order by ssn
+-----------+---------+
| ssn | fname |
+-----------+---------+
| 123456789 | John |
| 333445555 | Fanklin |
| 453453453 | Joyce |
| 666884444 | Ramesh |
| 888665555 | James |
+-----------+---------+
Answer:
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384&page=7 1/2
11/26/21, 3:51 PM Mock SQL Exam (Not for grading) (page 8 of 9)
Question 24
Show the last name of all employees who have female dependents order by last name.
+-------+
| lname |
+-------+
| Smith |
| Wong |
+-------+
Answer:
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384&page=7 2/2
11/26/21, 3:51 PM Mock SQL Exam (Not for grading) (page 9 of 9)
Dashboard / My courses / Term I [2021-22] / T1-21-22-CS301P / Topic 1 / Mock SQL Exam (Not for grading)
Question 25
Not yet answered
Show the last name of all employees who have female dependents order by last name.
+-------+
| lname |
+-------+
| Smith |
| Wong |
+-------+
Answer:
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384&page=8 1/2
11/26/21, 3:51 PM Mock SQL Exam (Not for grading) (page 9 of 9)
https://exam.iiitb.net/mod/quiz/attempt.php?attempt=10902&cmid=1384&page=8 2/2