Skip to main contentSkip to solution

Consider a table named 'SALE':

InvoiceNoCarIdCustIDDate_salepaymentEmpId
I001D001C0012017-01-24ChequeE002
I002S001C0022017-12-11CashE003
I003S002C0032018-09-15CashE005
I004D002C0012018-12-24ChequeE004
I005S003C0022020-07-15CashE002

What will be the SQL query to find the number of different customer IDs?

Solution

✅ Correct Option: 1

COUNT(DISTINCT CustID) counts each customer ID only once, so it returns the number of different customers. Here the CustID values are C001, C002, C003, C001, C002, so the result is 3\boxed{3}.


Option 2: lists the distinct IDs (C001, C002, C003) but does not count them.

Options 3 and 4: count rows without removing duplicates, so both return 5.

Keyboard Shortcuts

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