0% found this document useful (0 votes)
4 views3 pages

MySQL Practical Q6 Q10

Uploaded by

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

MySQL Practical Q6 Q10

Uploaded by

Eshu Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

MySQL Practical File Solutions (Q6 - Q25)

Q6: Write MySQL command to display the names of all employees in


uppercase.
Query:

SELECT UPPER(EMP_NAME) FROM EMPLOYEE;

Output:

+------------------+
| UPPER(EMP_NAME) |
+------------------+
| NEHA |
| RAJ |
| SIMRAN |
| ARJUN |
| RAVI |
| NISHA |
+------------------+
6 rows in set (0.00 sec)

Table Change: No change. Only displays EMP_NAME in uppercase.

Q7: Write MySQL command to display the name and year of birth of all
employees.
Query:

SELECT EMP_NAME, YEAR(EMP_DOB) AS Birth_Year FROM EMPLOYEE;

Output:

+---------+------------+
| EMP_NAME| Birth_Year|
+---------+------------+
| Neha | 2001|
| Raj | 2000|
| Simran | 1999|
| Arjun | 1998|
| Ravi | 2002|
| Nisha | 1997|
+---------+------------+
6 rows in set (0.00 sec)

Table Change: No change. Just extracts year from EMP_DOB.

Q8: Write MySQL command to display the average salary of employees.


Query:

SELECT AVG(SALARY) AS Average_Salary FROM EMPLOYEE;

Output:

+----------------+
| Average_Salary |
+----------------+
| 56666.67 |
+----------------+
1 row in set (0.00 sec)

Table Change: No change. Shows computed average salary.

Q9: Write MySQL command to display the maximum and minimum salary from
EMPLOYEE.
Query:

SELECT MAX(SALARY) AS Max_Salary, MIN(SALARY) AS Min_Salary FROM EMPLOYEE;

Output:

+------------+------------+
| Max_Salary | Min_Salary |
+------------+------------+
| 80000 | 30000 |
+------------+------------+
1 row in set (0.00 sec)

Table Change: No change. Shows maximum and minimum salary.


Q10: Write MySQL command to count number of employees in each
department.
Query:

SELECT DEPT_NO, COUNT(*) AS No_Of_Employees FROM EMPLOYEE GROUP BY DEPT_NO;

Output:

+---------+----------------+
| DEPT_NO | No_Of_Employees|
+---------+----------------+
| 1| 1|
| 2| 1|
| 3| 1|
| 4| 2|
| 5| 1|
+---------+----------------+
5 rows in set (0.00 sec)

Table Change: No change. Just groups employees by DEPT_NO.

You might also like