SQL COMMANDS…
1. Create the database loans.
2. Use database loans.
3. Create table loan_accounts and insert tuples in it.
4. Display details of all the loans.
5. Display the accno, cust_name and loan_amount of all the loans.
6. Display details of all the loans with less than 40 installments.
7. Display the accno and loan_amount of all the loans started before 01-04-2009.
8. Display the int_rate of all the loans started after 01-04-2009.
9. Display the details of all the loans whose rate of interest is null.
10. Display the amount of various loans from the table loan_accounts. A loan amount should appear only
once.
11. Display the cust_name and loan_amount for all the loans which do not have number of installments
36.
12. Display the cust_name and loan_amount for all the loans for which the loan amount is less than
500000 or int_rate is more than 12.
13. Display the details of all the loans whose rate of interest is in the range 11% to 12%.
14. Display the cust_name and loan_amount for all the loans for which the number of installments are 24,
36, or 48.
15. Display the details of all the loans whose loan_amount is in the range 400000 to 500000.
16. Display the accno, cust_name, loan_amount for all the loans for which the cust_name ends with
“Sharma”.
17. Display the accno, cust_name, and loan_amount for all the loans for which the cust_name contains ‘a’
as the second last character.
18. Display the details of all the loans in the ascending order of their loan_amount.
19. Display the details of all the loans in the descending order of their start_date.
20. Put the interest rate 11.50% for all the loans for which interest rate is null.
21. For each loan replace interest with (loan_amount * int_rate*installments)/12*100.
22. Delete the records of all the loans of “k.p. jain”.
23. Add another category of type char(1) in the loan_accounts table.
24. Find the output of the following :
a. Select cust_name , length(cust_name), lcase(cust_name),
Ucase(cust_name) from loan_accounts where int_rate <11.00;
b. Select left(cust_name,3), right(cust_name,3), substr(cust_name,1,3) from loan_accounts
where int_rate > 10.00;
c. Select dayname(start_date) from loan_accounts;
d. Select round(int_rate*110/100,2) from loan_accounts where int_rate >10;
25. Write the output produce by the following SQL commands :
a. Select pow(4,3), pow(3,4);
b. Select round(543.5694,2) , round(543.5694), round(543.5634,-1);
c. Select truncate(543.5694,2), truncate(543.5694,-1);
d. Select concat(“samandeep”, “ singh”) “full name”;
e. Select year(curdate()), month(curdate()), day(curdate());
f. Select instr(“Unicode”, “co”), instr(“Unicode”, “ cd”);
g. Select mid(“informatics”,3,4),substr(“practices”,3);