Question:

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.

Write the output of the following SQL Queries:
(i) SELECT SUBSTRING(EMP_NAME, 1, 5) FROM EMPLOYEE WHERE DEPT = 'ENGINEERING';
(ii) SELECT EMP_NAME FROM EMPLOYEE WHERE MONTH(JOIN_DATE) = 8;
(iii) SELECT EMP_NAME FROM EMPLOYEE WHERE SALARY>60000;
(iv) SELECT COUNT(DEPT) FROM EMPLOYEE;
 

Show Hint

Use SUBSTRING to extract parts of text, MONTH() to filter dates, and COUNT() skips NULL values by default.
Updated On: Jul 14, 2025
Hide Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

(i) Output for SUBSTRING query:
This query selects the first 5 characters of EMP_NAME where DEPT is ENGINEERING.
The employee in ENGINEERING is PRIYA JAIN.
First 5 characters: PRIYA.
So the output is:
PRIYA

(ii) Output for employees who joined in August (Month = 8):
This query checks the JOIN_DATE column for month equal to 8.
RAVI SHARMA joined on 2018-08-14, which is August.
So the output is:
RAVI SHARMA

(iii) Output for employees with salary greater than 60000:
This query lists EMP_NAMEs where SALARY>60000.
Employees with salaries greater than 60000 are:
- ARJUN SINGH (75000)
- PRIYA JAIN (85000)
So the output is:
ARJUN SINGH
PRIYA JAIN

(iv) Output for COUNT(DEPT):
This query counts how many DEPT entries are non-NULL.
Out of 5 records, AYESHA has a NULL DEPT, so only 4 rows are counted.
So the output is: 4
Was this answer helpful?
0
0

Top Questions on SQL Queries

View More Questions