The payments table records one row per payment a customer makes. Return a single column payment_method containing each distinct payment method in payments, ordered alphabetically.
Input Table(s)
payments
| Column | Type | Meaning |
|---|
| payment_id | INT | Payment id |
| customer_id | INT | Customer who made the payment, NOT NULL |
| amount | DECIMAL(10,2) | Payment amount, NOT NULL |
| payment_method | VARCHAR(50) | Method used for the payment, NOT NULL |
| payment_date | DATE | Date of the payment, NOT NULL |
Primary key: payment_id.
Output Contract
| Column | Type | Meaning |
|---|
| payment_method | VARCHAR(50) | One distinct payment method |
Return one row per distinct payment_method, ordered by payment_method ascending. The values are unique in the output, so the order is fully determined. There is nothing to round.
Example
payments
| payment_id | customer_id | amount | payment_method | payment_date |
|---|
| 1 | 101 | 25.00 | credit_card | 2024-01-05 |
| 2 | 102 | 40.50 | paypal | 2024-01-05 |
| 3 | 101 | 12.00 | credit_card | 2024-01-07 |
| 4 | 103 | 99.99 | bank_transfer | 2024-01-08 |
| 5 | 102 | 15.00 | paypal | 2024-01-09 |
Expected result
| payment_method |
|---|
| bank_transfer |
| credit_card |
| paypal |
Five payments use three methods. credit_card and paypal each appear twice but are listed once, and the three values are sorted alphabetically.
Constraints and Clarifications
-
payments
contains at least 1 row.
-
payment_method
is never NULL and is 1 to 50 characters long.
-
1 <= payment_id <= 10000
, so the table has at most 10,000 rows.
-
Values are compared exactly as stored. Two values that differ only in capitalization or spacing count as two different methods.
-
The other columns do not affect the result. A method used once and a method used a thousand times each appear once.