Q. 1 Consider a database LOANS with the following table:
Table: LOANS
Referring the above given table write the SQL queries for the following:
a) Create a Database Practical checking it’s pre-existence.
b) Create the above mention table. c) Fill in all the above given records in the table. d) Display the AccNo and Loan_Amount of all the loans started before 01-04- 2009. e) Display the AccNo, Cust_Name, and Loan_Amount of all the loans. f) Display the details of all the loans with less than 40 instalments. g) Display the details of all the loans whose rate of interest is NULL. h) Display the details of all the loans whose rate of interest is not NULL. i) Display the amounts of various loans from the table Loan_Accounts. A loan amount should appear only once. j) Display the details of all the loans started after 31-12-2008 for which the number of instalments are more than 36. k) Display the Cust_Name and Loan_Amount for all the loans which do not have number of instalments 36. l) Display the details of all the loans which started in the year 2009. m) Display the details of all the loans whose Loan_Amount is in the range 400000 to 500000. n) Display the Cust_Name and Loan_Amount for all the loans for which the number of instalments are 24, 36, or 48. (Using IN operator) o) Display the AccNo, Cust_Name, and Loan_Amount for all the loans for which the Cust_Name ends with 'Sharma'. p) Display the AccNo, Cust_Name, and Loan_Amount for all the loans for which the Cust_Name does not contain 'P'. q) Display the AccNo, Cust_Name, and Loan_Amount for all the loans for which the Cust_Name contains 'a' as the second last character. r) Display the details of all the loans in the descending order of their Start_Date. s) Display the details of all the loans in the ascending order of their Loan_Amount and within Loan_Amount in the descending order of their Start_Date. t) Increase the interest rate by 0.5% for all the loans for which the loan amount is more than 400000. u) Delete the records of all the loans whose start date is before 2007.
Q. 2 Consider a table EMPLOYEE with the following data and answer
the SQL queries:
Note : Take Area Code as “Area_Code” and Bonus (%) as “Bonus_Per”
1. Create database Office 2. Use the database Office 3. Create the above given Table “EMPLOYEE” 4. Insert the above given records in the table. 5. Display the details of all the employees. 6. Display the Employee No, Name, and Salary of all the employees. 7. Display the details of all the employees with salary less than 300000. 8. Display the eno and salary of all the employees who joined before 01-04-2009. 9. Display the eno, ename of all the employees who joined after 01- 04-2009. 10. Display the details of all the employees whose bonus is NULL. 11. Display the details of all the employees whose bonus is not NULL. 12. Display the salary of employees from the table removing duplicate values. 13. Display the area code of employees from the table Employees. An area code should appear only once. 14. Display the details of all the employees joined after 31-12-2008 for which the area code is more than 36. 15. Display the Name and salary for all the employees which do not have area code 36. 16. Display the Name and salary for all the employees for which the salary is less than 500000 or bonus is more than 12. 17. Display the details of all the employees who joined in the year 2009. 18. Display the details of all the employees whose salary is in the range 400000 to 500000. (Using relational operators). 19. Display the details of all the employees whose bonus is in the range 11% to 12%. (Using relational operators). 20. Display the Name and salary for all the employees for whom the bonus is 24, 36, or 48. (Using IN operator). 21. Display the details of all the employees whose salary is in the range 400000 to 500000. (Using BETWEEN operator). 22. Display the details of all the employees whose bonus is in the range11% to 12%. (Using BETWEEN operator). 23. Display the Eno, Name, and Salary for all the employees for whom the Name ends with 'Sharma'. 24. Display the Eno, Name, and salary for all the employees for whom the Name ends with 'a'. 25. Display the Eno, Name, and Salary for all the employees for whom the Name contains 'a'. 26. Display the Eno, Name, and Salary for all the employees for whom the Name does not contain 'P'. 27. Display the Eno, Name, and Salary for all the employees for whom the Name contains 'a' as the second last character. 28. Display the details of all the employees in the ascending order of their salary. 29. Display the details of all the employees in the descending order of their join date. 30. Display the details of all the employees in the ascending order of their salary and within salary in the descending order of their join Date. 31. Assign the bonus 15.50% for all the employees for which bonus is NULL. 32. Increase the bonus by 0.5% for all the employees for which the salary is more than 400000. 33. For every employees replace bonus with (salary*bonus)/12*100. 34. Delete the records of employee, 'N.P.Jain'. 35. Add another column Category of type CHAR(5) in the Employees table.