Given table 'SALE':
carid saledate paymentmode saleprice D001 2019-01-24 Credit Card 613248.00 D002 2019-01-25 Cheque 604000.00 E001 2019-01-30 Credit Card 620214.00
Find the output for:
SELECT COUNT(DISTINCT PAYMENTMODE) FROM SALE;
Given table 'SALE':
| carid | saledate | paymentmode | saleprice |
|---|---|---|---|
| D001 | 2019-01-24 | Credit Card | 613248.00 |
| D002 | 2019-01-25 | Cheque | 604000.00 |
| E001 | 2019-01-30 | Credit Card | 620214.00 |
Find the output for:
SELECT COUNT(DISTINCT PAYMENTMODE) FROM SALE;
Solution
✅ Correct Option: 3
COUNT(DISTINCT PAYMENTMODE) counts each different non-null value of PAYMENTMODE once. The column holds Credit Card, Cheque and Credit Card, so there are 2 distinct values and the output is 2.
Option 2: 3 is the result of COUNT(PAYMENTMODE) or COUNT(*), which count every row including the repeated Credit Card.
Options 1 and 4: these list values like a SELECT DISTINCT or a plain SELECT would. COUNT returns a single number, not a list of rows.
Related questions:
2026: 26 May Shift 1
2025: 21 May Shift 1
2026: 11 May Shift 2
2025: 15 May Shift 2