Skip to content
Worked Examples · Example 9.18

Q.In order to increase sales, suppose the car dealer decides to offer his customers to pay the total amount in 10 easy EMIs (equal monthly instalments). Assume that EMIs are required to be in multiples of 10000. For that, the dealer wants to list the CarID and Price along with the following data from the Inventory table:

a) Calculate GST as 12 per cent of Price and display the result after rounding it off to one decimal place.
b) Add a new column FinalPrice to the table inventory which will have the value as sum of Price and 12 per cent of the GST.
c) Calculate and display the amount to be paid each month (in multiples of 1000) which is to be calculated after dividing the FinalPrice of the car into 10 instalments.
d) After dividing the amount into EMIs, find out the remaining amount to be paid immediately, by performing modular division.
Rajasthan RbseTextbookSubjective· 3mImportance★★★★★
35% · 33/95 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

This walks through the real CARSHOWROOM INVENTORY table (Table 9.9) using SQL's numeric functions: ROUND() for the GST, ALTER TABLE + UPDATE to add and fill FinalPrice, and a combined ROUND()/MOD() expression to get the EMI (in multiples of 1000) and the balance left to pay right away.

The real INVENTORY table (Table 9.9)

CarIdCarNamePriceModelYearManufactureFuelType
D001Dzire582613.00LXI2017Petrol
D002Dzire673112.00VXI2018Petrol
B001Baleno567031.00Sigma1.22019Petrol
B002Baleno647858.00Delta1.22018Petrol
E001EECO355205.005 STR STD2017CNG
E002EECO654914.00CARE2018CNG
S001SWIFT514000.00LXI2017Petrol
S002SWIFT614000.00VXI2018Petrol

(a) GST = 12% of Price, rounded to one decimal place

GST = ROUND(12/100 × Price, 1)

SELECT ROUND(12/100*Price,1) "GST" FROM INVENTORY;

Output (rows follow CarId order D001, D002, B001, B002, E001, E002, S001, S002)

+------------+
| GST        |
+------------+
| 69913.6    |
| 80773.4    |
| 68043.7    |
| 77743.0    |
| 42624.6    |
| 78589.7    |
| 61680.0    |
| 73680.0    |
+------------+
8 rows in set (0.00 sec)

(b) Add and fill the FinalPrice column

ALTER TABLE (a DDL command) creates the empty column; UPDATE (a DML command) fills it as Price + the rounded 12% GST.

ALTER TABLE INVENTORY ADD(FinalPrice Numeric(10,1));

UPDATE INVENTORY SET FinalPrice=Price+Round(Price*12/100,1);

SELECT * FROM INVENTORY;

Output

CarIdPriceModelFinalPrice
D001582613.00LXI652526.6
D002673112.00VXI753885.4
B001567031.00Sigma1.2635074.7
B002647858.00Delta1.2725601.0
E001355205.005 STR STD397829.6
E002654914.00CARE733503.7
S001514000.00LXI575680.0
S002614000.00VXI687680.0

8 rows in set (0.00 sec)


(c) and (d) EMI (multiples of 1000) and the balance payable now

EMI = ROUND(FinalPrice − MOD(FinalPrice,1000)/10, 0)

Remaining Amount = MOD(FinalPrice, 10000)

SELECT CarId, FinalPrice, ROUND(FinalPrice-MOD(FinalPrice,1000)/10,0) "EMI",
       MOD(FinalPrice,10000) "Remaining Amount"
FROM INVENTORY;

Output

| CarId | FinalPrice | EMI | Remaining Amount | …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.