Practical assignment 2 cs class 12
Practical assignment 2 cs class 12
-- Table: Loan_Accounts
-- | AccNo | Cust_Name | Loan_Amount | Instalments | Int_Rate | Start_Date | Interest |
-- |-------|------------|-------------|-------------|----------|------------|----------|
-- | 1 | R. K. Gupta| 300000 | 36 | 12.00 | 19-07-2009 | Null |
-- | 2 | S. P. Sharma| 500000 | 48 | 10.00 | 22-03-2008 | Null |
-- | 3 | K. P. Jain | 300000 | 36 | NULL | 08-03-2007 | Null |
-- | 4 | M. P. Yadav| 800000 | 60 | 10.00 | 06-12-2008 | Null |
-- | 5 | S. P. Sinha| 200000 | 36 | 12.50 | 03-01-2010 | Null |
-- | 6 | P. Sharma | 700000 | 60 | 12.50 | 05-06-2008 | Null |
-- | 7 | K. S. Dhall| 500000 | 48 | NULL | 05-03-2008 | Null |
-- Output:
-- Query OK, 1 row affected (0.01 sec) [for each insert]
-- (ii) Put the interest rate (Int_rate) as 11.50% on loan amount for the loans for which interest
rate is missing
UPDATE Loan_Accounts
SET Int_Rate = 11.50
WHERE Int_Rate IS NULL;
-- Output:
-- Query OK, 2 rows affected (0.01 sec)
-- (iii) Increase the interest rate by 0.5% for the loans for which the loan amount is more than
400000
UPDATE Loan_Accounts
SET Int_Rate = Int_Rate + 0.5
WHERE Loan_Amount > 400000;
-- Output:
-- Query OK, 4 rows affected (0.01 sec)
-- (iv) For each loan replace interest with (Loan_Amount * Int_Rate * Instalments) / (12 * 100)
UPDATE Loan_Accounts
SET Interest = (Loan_Amount * Int_Rate * Instalments) / (12 * 100);
-- Output:
-- Query OK, 9 rows affected (0.01 sec)
-- (v) Remove the records of all the loans whose start date is before 2007
DELETE FROM Loan_Accounts
WHERE Start_Date < '2007-01-01';
-- Output:
-- Query OK, 0 rows affected (0.01 sec)
-- Output:
-- Query OK, 1 row affected (0.01 sec)
-- Output:
-- Query OK, 8 rows affected (0.01 sec)