(a) An educational institution is maintaining a database for storing the details of courses being offered. The database includes a table COURSE with the following attributes: C_ID: Stores the unique ID for each course. C_NAME: Stores the course's name. INSTRUCTOR: Stores the name of the course instructor. DURATION: Stores the duration of the course in hours.
Table: COURSE
| C_ID | C_NAME | INSTRUCTOR | DURATION |
|---|---|---|---|
| C101 | Data Structures | Dr. Alok | 40 |
| C102 | Machine Learning | Prof. Sunita | 60 |
| C103 | Web Development | Ms. Sakshi | 45 |
| C104 | Database Management | Mr. Suresh | 50 |
| C105 | Python Programming | Dr. Pawan | 35 |
Write SQL queries for the following:
- To add a new record with following specifications: C_ID: C106 C_NAME: Introduction to AI INSTRUCTOR: Ms. Preeti DURATION: 55
- To display the longest duration among all courses.
- To count total number of courses run by the institution.
- To display the instructors' name in lower case. OR
(b) Ashutosh, who is a manager, has created a database to manage employee records. The database includes a table named EMPLOYEE whose attribute names are mentioned below: EID: Stores the unique ID for each employee. EMP_NAME: Stores the name of the employee. DEPT: Stores the department of the employee. SALARY: Stores the salary of the employee. JOIN_DATE: Stores the employee's joining date.
Table: EMPLOYEE
| EID | EMP_NAME | DEPT | SALARY | JOIN_DATE |
|---|---|---|---|---|
| E01 | ARJUN SINGH | SALES | 75000 | 2019-11-01 |
| E02 | PRIYA JAIN | ENGINEERING | 85000 | 2020-05-20 |
| E03 | RAVI SHARMA | MARKETING | 60000 | 2018-08-14 |
| E04 | AYESHA | NULL | 50000 | 2021-01-10 |
| E05 | RAHUL VERMA | FINANCE | 40000 | 2017-06-25 |
Write the output of the following SQL Queries:
- Select SUBSTRING(EMP_NAME, 1, 5) from EMPLOYEE where DEPT = 'ENGINEERING';
- Select EMP_NAME from EMPLOYEE where month(JOIN_DATE) = 8;
- Select EMP_NAME from EMPLOYEE where SALARY > 60000;
- Select count(DEPT) from EMPLOYEE;
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Part (a): INSERT C106; MAX(DURATION)=60; COUNT(*)=6 (after insert); LOWER(INSTRUCTOR) lowercases each name.
Part (b): (i) PRIYA, (ii) RAVI SHARMA, (iii) ARJUN SINGH & PRIYA JAIN, (iv) 4.
Part (a) — writing queries on COURSE
(i) Insert a record. Supply values in column order; strings quoted, the number bare.
INSERT INTO COURSE VALUES ('C106', 'Introduction to AI', 'Ms. Preeti', 55);
(ii) Longest duration. MAX returns the largest DURATION.
SELECT MAX(DURATION) FROM COURSE;
MAX(DURATION)
60
(iii) Count of courses. COUNT(*) tallies all rows. After part (i) the table holds 6 rows (5 originally).
SELECT COUNT(*) FROM COURSE;
COUNT(*)
6
(iv) Instructor names in lower case. LOWER() converts each string to lowercase.
SELECT LOWER(INSTRUCTOR) FROM COURSE;
LOWER(INSTRUCTOR)
dr. alok
prof. sunita
ms. sakshi
mr. suresh
dr. pawan …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.