Count Distinct Over Partition

Easy
4
72.7% Acceptance

Table Used: InvoiceLine

Objective: The participant is required to count the distinct tracks associated with each invoice.

Details:

  • Output Columns:
    1. InvoiceId
    2. DistinctTracksCount - Represents the number of unique tracks for each invoice.
  • Write an SQL query to retrieve the above columns from the InvoiceLine table.
  • Ensure that you're counting only distinct tracks for each invoice.
  • Order: The result should be ordered by InvoiceId.

Expected Columns in Result:

  • InvoiceId
  • DistinctTracksCount