Q.Using the SALE table of the CARSHOWROOM database:
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 →Add a Commission column to the real SALE table, fill it with 12% of SalePrice, then filter and round it — using MySQL's ADD(...), UPDATE ... SET, WHERE, and ROUND().
This is a code/query task on the SALE table of the CARSHOWROOM database — the same six rows used throughout this chapter:
| InvoiceNo | CarId | CustId | SaleDate | PaymentMode | EmpID | SalePrice |
|---|---|---|---|---|---|---|
| I00001 | D001 | C0001 | 2019-01-24 | Credit Card | E004 | 613247.00 |
| I00002 | S001 | C0002 | 2018-12-12 | Online | E001 | 590321.00 |
| I00003 | S002 | C0004 | 2019-01-25 | Cheque | E010 | 604000.00 |
| I00004 | D002 | C0001 | 2018-10-15 | Bank Finance | E007 | 659982.00 |
| I00005 | E001 | C0003 | 2018-12-20 | Credit Card | E002 | 369310.00 |
| I00006 | S002 | C0002 | 2019-01-30 | Bank Finance | E007 | 620214.00 |
(a) ALTER TABLE ... ADD(column type) creates the new column:
ALTER TABLE SALE ADD(Commission Numeric(7,2));
Numeric(7,2) gives a total of 7 digits with 2 after the decimal point — enough for commissions up to 99999.99.
(b) Fill it with 12% of SalePrice, then filter:
UPDATE SALE SET Commission=12/100*SalePrice;
SELECT * FROM SALE WHERE Commission > 73000;
12/100*SalePrice computes 12% of each row's SalePrice. Checking every row: I00001 → 73589.64, I00002 → 70838.52, I00003 → 72480.00, I00004 → 79197.84, I00005 → 44317.20, I00006 → 74425.68. Only three exceed 73000:
| InvoiceNo | CarId | CustId | SaleDate | PaymentMode | EmpID | SalePrice | Commission |
|---|---|---|---|---|---|---|---|
| I00001 | D001 | C0001 | 2019-01-24 | Credit Card | E004 | 613247.00 | 73589.64 |
| I00004 | D002 | C0001 | 2018-10-15 | Bank Finance | E007 | 659982.00 | 79197.84 |
| I00006 | S002 | C0002 | 2019-01-30 | Bank Finance | E007 | 620214.00 | 74425.68 |
I00002's commission (70838.52) is close to 73000 but still below it — don't round early and accidentally include it. Compare the full-precision value against the threshold. …
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.