0% found this document useful (0 votes)
7 views

SQL Mock Quiz 1 Questions

Uploaded by

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

SQL Mock Quiz 1 Questions

Uploaded by

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

11/26/21, 3:50 PM Mock SQL Exam (Not for grading) (page 1 of 9)

Dashboard / My courses / Term I [2021-22] / T1-21-22-CS301P / Topic 1 / Mock SQL Exam (Not for grading)

Question 1
Not yet answered

Marked out of 1.00

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

Marked out of 1.00

Display the age of all employees ordered by increasing age.

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

Not yet answered

Marked out of 1.00

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

7 rows in set (0.00 sec)

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

Marked out of 1.00

List of employees whose salary is greater than their department average

and sort the result by the firrst name.

sample output:
+----------+

| fname |
+----------+

| Franklin |
| Jennifer |

| Ramesh |

+----------+
3 rows in set (0.00 sec)

Answer:

Question 5
Not yet answered

Marked out of 1.00

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

| James | E | Borg | 888665555 | 1937-01-09 | 450 Fondren, Houston, TX | M | 55000 | NULL | 1|


| Ramesh | K | Narayan | 666884444 | 1962-01-09 | 975 Fondren, Houston, TX | M | 38000 | 333445555 | 5|

+--------+-------+---------+-----------+------------+--------------------------+------+--------+-----------+------+

2 rows in set (0.00 sec)

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

Not yet answered

Marked out of 1.00

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|

| Joyce |A | English | 453453453 | 1972-01-09 | 5631 Fondren, Houston, TX | F | 25000 | 333445555 | 5|


| Ahmad |V | Jabbar | 987987987 | 1969-01-09 | 980 Fondren, Houston, TX | M | 25000 | 987654321 | 4|

| Ramesh | K | Narayan | 666884444 | 1962-01-09 | 975 Fondren, Houston, TX | M | 38000 | 333445555 | 5|


| John |B | Smith | 123456789 | 1965-01-09 | 731 Fondren, Houston, TX | M | 30000 | 333445555 | 5|

| Jennifer | S | Wallace | 987654321 | 1941-01-09 | 21 Fondren, Houston, TX | F | 43000 | 888665555 | 4|


| Franklin | T | Wong | 333445555 | 1955-01-09 | 638 Fondren, Houston, TX | M | 40000 | 888665555 | 5|

| Alicia | J | Zelaya | 999887777 | 1968-01-09 | 3321 Fondren, Houston, TX | F | 25000 | 987654321 | 4|

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

Marked out of 1.00

Find different project locations alphabetically.

sample output:
+-----------+
| plocation |

+-----------+
| Bellaire |

| Houston |

| Stafford |
| Sugarland |

+-----------+

Answer:

Question 8
Not yet answered

Marked out of 1.00

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 |

+----------+-------+---------+-----------+------------+--------------------------+------+--------+-----------+------+

| Ahmad |V | Jabbar | 987987987 | 1969-01-09 | 980 Fondren, Houston, TX | M | 25000 | 987654321 | 4|


| John |B | Smith | 123456789 | 1965-01-09 | 731 Fondren, Houston, TX | M | 30000 | 333445555 | 5|

| Ramesh | K | Narayan | 666884444 | 1962-01-09 | 975 Fondren, Houston, TX | M | 38000 | 333445555 | 5|


| Franklin | T | Wong | 333445555 | 1955-01-09 | 638 Fondren, Houston, TX | M | 40000 | 888665555 | 5|

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

Not yet answered

Marked out of 1.00

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|

| Ahmad | V | Jabbar | 987987987 | 1969-01-09 | 980 Fondren, Houston, TX | M | 25000 | 987654321 | 4|


| Alicia | J | Zelaya | 999887777 | 1968-01-09 | 3321 Fondren, Houston, TX | F | 25000 | 987654321 | 4|

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

Marked out of 1.00

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

Marked out of 1.00

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

| Ahmad | V | Jabbar | 987987987 | 1969-01-09 | 980 Fondren, Houston, TX | M | 25000 | 987654321 | 4|

| Alicia | J | Zelaya | 999887777 | 1968-01-09 | 3321 Fondren, Houston, TX | F | 25000 | 987654321 | 4|


| James | E | Borg | 888665555 | 1937-01-09 | 450 Fondren, Houston, TX | M | 55000 | NULL | 1|

| Joyce | A | English | 453453453 | 1972-01-09 | 5631 Fondren, Houston, TX | F | 25000 | 333445555 | 5|


| Ramesh | K | Narayan | 666884444 | 1962-01-09 | 975 Fondren, Houston, TX | M | 38000 | 333445555 | 5|

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

Not yet answered

Marked out of 1.00

Find minimum salary under the Research department.

+-------------+
| min(salary) |

+-------------+

| 25000 |
+-------------+

1 row in set (0.13 sec)

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

Marked out of 1.00

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

Marked out of 1.00

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

Not yet answered

Marked out of 1.00

Show the count of employees who belong to department 5.

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

Marked out of 1.00

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

Not yet answered

Marked out of 1.00

Show the minimum salary of employees in the Administration department

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

Not yet answered

Marked out of 1.00

Show the average number of hours worked on Project Computerization

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

Marked out of 1.00

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

Marked out of 1.00

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

Not yet answered

Marked out of 1.00

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

Marked out of 1.00

Show ssn,first name and department name they belong to for all employees order by ssn

+-----------+----------+----------------+
| ssn | fname | dname |

+-----------+----------+----------------+
| 123456789 | John | Research |

| 333445555 | Fanklin | Research |


| 453453453 | Joyce | Research |

| 666884444 | Ramesh | Research |

| 888665555 | James | Headquarters |


| 987654321 | Jennifer | Administration |

| 987987987 | Ahmad | Administration |


| 999887777 | Alicia | Administration |

+-----------+----------+----------------+

Answer:

Question 23

Not yet answered

Marked out of 1.00

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

Not yet answered

Marked out of 1.00

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

Marked out of 1.00

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

You might also like