Monday, July 4, 2022

MySql Query Exercise - INBUILT FUNCTION

Emp_Details:
+-------------+-------------+-------------+----------+------------+------------+------------+----------+----------------+------------+---------------+
| EMPLOYEE_ID | FIRST_NAME  | LAST_NAME   | EMAIL    |PHONE_NUMBER| HIRE_DATE  | JOB_ID     | SALARY   | COMMISSION_PCT | MANAGER_ID | DEPARTMENT_ID |
+-------------+-------------+-------------+----------+------------+------------+------------+----------+----------------+------------+---------------+
|         100 | Steven      | King        | SKING    | 9436489565 | 2000-06-17 | AD_PRES    | 24000.00 |           0.00 |          0 |   		  90 |
|         101 | Neena       | Kochhar     | NKOCHHAR | 9436489365 | 1987-06-18 | AD_VP      | 17000.00 |           1.40 |        100 |            90 |
|         102 | Lex         | De Haan     | LDEHAAN  | 9436489465 | 1987-09-19 | AD_VP      | 17000.00 |           0.30 |        100 |            90 |
|         103 | Alexander   | Hunold      | AHUNOLD  | 9436489565 | 1989-06-20 | IT_PROG    |  9000.00 |           1.00 |        102 |            60 |
|         104 | Bruce       | Ernst       | BERNST   | 9436489765 | 1989-06-21 | IT_PROG    |  6000.00 |           0.00 |        103 |            60 |
|         105 | David       | Austin      | DAUSTIN  | 9436489585 | 1999-07-22 | IT_PROG    |  4800.00 |           2.50 |        103 |            60 |
|         106 | Valli       | Pataballa   | VPATABAL | 9436489565 | 1987-07-23 | IT_PROG    |  4800.00 |           0.00 |        103 |            60 |
|         107 | Diana       | Lorentz     | DLORENTZ | 9436439565 | 1999-08-24 | IT_PROG    |  4200.00 |           1.20 |        103 |            60 |
|         108 | Nancy       | Greenberg   | NGREENBE | 9436487565 | 1987-08-25 | FI_MGR     | 12000.00 |           0.00 |        101 |           100 |
|         109 | Daniel      | Faviet      | DFAVIET  | 9436488565 | 2000-06-26 | FI_ACCOUNT |  9000.00 |           4.00 |        108 |           100 |
+-------------+-------------+-------------+----------+------------+------------+------------+----------+----------------+------------+---------------+

AGGREGATION FUNCTION:
Write Query for the following:
1. Write a query to list the number of jobs available in the emp_details table.
2. Write a query to get the total salaries payable to employees.
3. Write a query to get the minimum salary from emp_details table.
4. Write a query to get the maximum salary of an employee working as a Programmer.
5. Write a query to get the average salary and number of employees working the department 90.
6. Write a query to get the highest, lowest, sum, and average salary of all employees.
7. Write a query to get the number of employees with the same job.
8. Write a query to get the difference between the highest and lowest salaries.>
9. Write a query to find the manager ID and the salary of the lowest-paid employee for that manager.
10. Write a query to get the department ID and the total salary payable in each department. 
DATE FUNCTION
  1. Write a query to get the first name and hire date from emp_details table where hire date between '1987-06-01' and '1989-07-30'.
  2. Write a query to get the firstname, lastname who joined in the month of June.
  3. Write a query to get first name of employees who joined in 1989.
  4. Write a query to get department name, manager name, and salary of the manager for all managers whose experience is more than 6 years
  
TEXT FUNCTION
  1. Write a query to get the full name and hire date of the employees where the length of the first name greater than or equal to 7. 
  2. Write a query to append '@google.com' to email field.
  3. Write a query that displays the first name and the length of the first name for all employees whose name starts with the letters 'A'.
  4. Write a query display 3 character from the first name starting form  the 3rd character.
  
   
Math FUNCTION
    1. Write a query to round the commission percentage to 0 decimal place.
    
Reference: 1. www.w3resource.com
Share: