5
5
```sql
Deptname VARCHAR(50),
Location VARCHAR(50)
);
EmpName VARCHAR(50),
Job VARCHAR(50),
Manager INT,
HireDate DATE,
Deptno INT,
);
HighSalary DECIMAL(10, 2)
);
```
```sql
INSERT INTO Employee VALUES (101, ‘John Doe’, ‘Manager’, NULL, ‘1980-06-15’, 5000,
NULL, 1);
INSERT INTO Employee VALUES (102, ‘Jane Smith’, ‘Clerk’, 101, ‘1981-07-20’, 3000,
NULL, 2);
INSERT INTO Employee VALUES (103, ‘Alice Johnson’, ‘Analyst’, 101, ‘1981-11-15’, 4000,
NULL, 3);
```
1. **List employee names who have joined between the months July to December
of the year 1981.**
```sql
SELECT EmpName
FROM Employee
```
2. **List employee details including department and their grade based on the
salary of all the employees except clerks.**
```sql
FROM Employee E
```
3. **List the employees whose name should not start with a letter ‘A’ and should
not end with a letter ‘A’ but it should be there in the name.**
```sql
SELECT EmpName
FROM Employee
WHERE EmpName LIKE ‘%A%’ AND EmpName NOT LIKE ‘A%’ AND EmpName NOT LIKE
‘%A’;
```
4. **Find all the employees who have joined the company before their managers.**
```sql
SELECT E1.EmpName
FROM Employee E1
```
5. **List the name of employees who have finished their 25 years of experience in
the company.**
```sql
SELECT EmpName
FROM Employee
```
6. **List the employee name, salary, PF, HRA, DA and gross; order the results in the
ascending order of gross.**
```sql
FROM Employee
```
7. **List the departments for which no employee is working.**
```sql
SELECT Deptname
FROM Department D
```
8. **List the department name, number of employees working, total salary, average
salary, maximum salary and minimum salary in each of the department.**
```sql
SELECT D.Deptname,
COUNT(E.EmpNo) AS NumEmployees,
SUM(E.Salary) AS TotalSalary,
AVG(E.Salary) AS AvgSalary,
MAX(E.Salary) AS MaxSalary,
MIN(E.Salary) AS MinSalary
FROM Department D
GROUP BY D.Deptname;
```
9. **List year in which most of the employees have joined the organization (Display
the year and no of employees).**
```sql
GROUP BY YEAR(HireDate)
LIMIT 1;
```
```sql
SELECT D.Deptname
FROM Department D
GROUP BY D.Deptname
LIMIT 1;
```