Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

CMREC_DBMS_WEEK 6_SU

Test Summary
No. of Sections: 1
No. of Questions: 5
Total Duration: 30 min

Section 1 - COD
Section Summary
No. of Questions: 5
Duration: 30 min

Additional Instructions:
None

Q1. Problem Statement


From the following tables, write a SQL query to find all the orders issued by the salesm

Sample table: salesman

Sample table: orders

Note: Table names and column names are case-sensitive.

Input Format

The input records are already prepopulated, as given in the problem statement.

Output Format

The output will display the orders issued by the salesman 'Paul Adam'.

Refer to the sample output for the column headers


ord_no purch_amt ord_date customer_id salesman_id
70011 75.29 2012-08-17 3003 5007

Sample Input Sample O

ord_
7001

Time Limit: - ms Memory Limit: - kb Code Size: - kb

Q2. Problem Statement

In a university, there are multiple courses and students. We have a database with two
"age". The "enrollments" table has columns "student_id" and "course_name". Write an S
another student is also enrolled in.

Students table (Example)


enrollments table (Example)

Input Format

The input records are already prepopulated, as given in the problem statement.

Output Format

Refer to the below sample output and its header


name1
Mike
Isolabella
Shravya
Supriya

Sample Input Sample O

name
Mike
Isol
Shra
Time Limit: - ms Memory Limit: - kb Code Size: - kb

Q3. Problem Statement

Write a SQL query to find those employees who work in a department where the emplo
emp_det table(Example)

Input Format

The input records are already prepopulated, as given in the problem statement.

Output Format

Refer to the below sample output and its header


emp_id first_name last_name
123 S Arvind
124 Sj Kumar
234 Sk Seema
235 k lahari
256 Sd venkat

Sample Input Sample O

emp_
123
124
234
Time Limit: - ms Memory Limit: - kb Code Size: - kb
Q4. Problem Statement

Consider to the table "emp_det" which has column values "emp_id", "fist_name", "last_
employees who earn more than an employee whose last name is 'Arvind'. Sort the resul
emp_det table(Example)

Input Format

The input records are already prepopulated, as given in the problem statement.

Output Format

Refer to the sample output for the column headers

emp_id first_name last_name email person_id dept_id salary


124 Sj Kumar Kumarewrr 123 132 55000
234 Sk Seema seemasdk 11 15 55000
256 Sd venkat venkarewar 1455 145 51500

Sample Input Sample O

emp_
124
234
256
Time Limit: - ms Memory Limit: - kb Code Size: - kb

Q5. Problem Statement

Write a query to find departments for a particular location. The location matches the l
dept_det table(Example)

Input Format

The input records are already prepopulated, as given in the problem statement.

Output Format

Refer to the below sample output and its header


name1 dept_id
HR 30

Sample Input Sample O

name
HR

Answer Key & So


Section 1 - CODING
Q1 Test Case

Input Output
ord_no pu
70011 75

Weightage - 100

Sample Input Sample Output

ord_no pu
70011 75

Solution

SELECT *
FROM orders
WHERE salesman_id =
(SELECT salesman_id
FROM salesman
WHERE name='Paul Adam');

Q2
Test Case

Input Output

nam
Mik
Iso
Shr

Weightage - 100

Sample Input Sample

nam
Mik
Iso
Shr

Solution

SELECT name1
FROM Students
WHERE id IN (
SELECT DISTINCT e1.student_id
FROM enrollments e1
WHERE e1.course_name IN (
SELECT e2.course_name
FROM enrollments e2
WHERE e2.student_id != e1.student_id
)
)

Q3
Test Case

Input Output
emp_id fi
123 S
124 Sj
234 Sk

Weightage - 100

Sample Input Sample Output

emp_id fi
123 S
124 Sj
234 Sk

Solution

SELECT emp_id, first_name, last_name


FROM emp_det
WHERE dept_id IN
( SELECT dept_id
FROM emp_det
WHERE first_name LIKE '%S%' );

Q4
Test Case

Input Output

emp
124
234

Weightage - 100

Sample Input Sample

emp
124
234

Solution

SELECT *from emp_det where salary >(select salary from emp_det where last_name

Q5 Test Case

Input Output

nam
HR

Weightage - 100

Sample Input Sample


name1 de
HR 30

Solution

SELECT name1, dept_id


FROM dept_det
WHERE location_id =
(
SELECT location_id
FROM dept_det
WHERE dept_id = 30);

You might also like