SQL Queries
SQL Queries
Write SQL commands for the tasks 1 to 35 and write the output for the SQL
2. Use loans;
Display the details of all the loans with less than 40 instalments.
Display the AccNo and Loan_Amount of all the loans started before 01-04-2009.
Display the details of all the loans whose rate of interest is not NULL
Display the amounts of various loans from the table Loan_Accounts. A loan amount should
appear only once.
Display the number of instalments of various loans from the table Loan_Accounts. An
instalment should appear only once.
Display the details of all the loans started after 31-12-2008 for which the number of
instalments are more than 36
Display the details of all the loans started after 31-12-2008 for which the number of
instalments are more than 36
Display the details of all the loans which started in the year 2009.
Display the details of all the loans whose Loan_Amount is in the range 400000 to 500000.
17. Select * from loan_accounts where loan_amount between 400000 and 500000;
Display the details of all the loans whose rate of interest is in the range 11% to 12%.
18. Select * from Loan_Accounts where Int_Rate >= 11 and Int_Rate <= 12
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)
19. Select Cust_Name, Loan_Amount from Loan_Accounts where Instalments in (24, 36, 48);
Display the details of all the loans whose Loan_Amount is in the range 400000 to 500000.
(Using BETWEEN operator)
20. Select * from Loan_Accounts where Loan_Amount Between 400000 and 500000;
Display the details of all the loans whose rate of interest is in the range 11% to 12%. (Using
BETWEEN operator)
22. Select AccNO, Cust_Name, Loan_Amount from Loans Where Cust_name is like ‘%sharma’;
Display the AccNo, Cust_Name, and Loan_Amount for all the loans for which the Cust_Name ends
with 'a'.
23. Select AccNo, Cust_Name, Loan_Amount from Loans Where Cust_Name like ‘%a’;
Display the AccNo, Cust_Name, and Loan_Amount for all the loans for which the Cust_Name
contains 'a'
Display the AccNo, Cust_Name, and Loan_Amount for all the loans for which the Cust_Name does
not contain 'P'.
Display the AccNo, Cust_Name, and Loan_Amount for all the loans for which the Cust_Name
contains 'a' as the second last character
Display the details of all the loans in the ascending order of their Loan_Amount.
Display the details of all the loans in the descending order of their Start_Date.
Put the interest rate 11.50% for all the loans for which interest rate is NULL.
Increase the interest rate by 0.5% for all the loans for which the loan amount is more than
400000.
Delete the records of all the loans whose start date is before 2007.
| pta | Gupta |
| rma | Sharma |
| dav | Yadav |
| nha | Sinha |
| rma | harma |
| ali | Dhali |
39. Find the Output of the following query
| Sunday |
| Saturday |
| Saturday |
| Sunday |
| Thursday |
| Wednesday |