Untitled Document (2)
Untitled Document (2)
4. Change the data type of Salary to CHAR(10) in the employee table (Not recommended):
INSERT INTO employee (Emp_id, Dept_id, Emp_name, Designation, Salary, contact_no, city)
VALUES (emp-1, dep-1, 'S Ahmad', 'Sales Mgr', 50000, 0110, New Delhi),
(emp-2, dep-2, 'Anand', 'Senior Mgr', 40000, 0111, New Delhi),
(emp-3, dep-3, 'Aruna', 'Accounts Mgr', 45000, 0112, New Delhi),
(emp-4, dep-3, 'Alpesh', 'Accountant', 35000, 0113, Banglore),
(emp-5, dep-1, 'Monica', 'Incharge', 25000, 0114, Noida),
(emp-6, dep-1, 'Harish', 'Sales Man', 15000, 0115, Banglore);
SELECT *
FROM employee
WHERE Salary > 30000;
10. Select details of employees with a salary between 15000 and 30000:
SELECT *
FROM employee
WHERE Salary BETWEEN 15000 AND 30000;
11. Select all details of employees who live in 'Bangalore' or 'New Delhi' (assuming a City
column exists):
SELECT *
FROM employee
WHERE City IN ('Bangalore', 'New Delhi');
12. Select all details of employees who do not stay in 'Bangalore' and 'New Delhi'
(assuming a City column exists):
SELECT *
FROM employee
WHERE City NOT IN ('Bangalore', 'New Delhi');
13. Select details of employees whose name starts with the character 'A':
SELECT *
FROM employee
WHERE Emp_name LIKE 'A%';
SELECT *
FROM employee
ORDER BY Salary DESC;
16. Get department ID, salary, and average salary for departments with an average salary
greater than 30000:
SQL
INSERT INTO Dept (Id, Dept, Emp_id)
VALUES (1, 'IT BILLING', 1),
(2, 'ENGINEERING', 2),
(3, ‘FINANCE', 41);
CALL GetEmployeeDetails(2);
SQL
CREATE VIEW EmployeeDetails AS
SELECT c.Emp_id, c.Name, d.Dept, d.Id, c.Age, c.Salary
FROM Company c
INNER JOIN Dept d ON c.Emp_id = d.Emp_id;