Skip to main contentSkip to solution

Given table 'SALE':

caridsaledatepaymentmodesaleprice
D0012019-01-24Credit Card613248.00
D0022019-01-25Cheque604000.00
E0012019-01-30Credit Card620214.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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question