MediumSQL

Subscriptions Started in 2024

SQLDatabases

Write a SQL query that returns all users who subscribed in the year 2024,
showing user_name, plan, and start_date, ordered by start_date.

Table: `subscriptions`

iduser_nameplanstart_date
1AlicePro2023-11-15
2BobFree2024-02-20
3CarolPro2024-06-01
4DaveTeams2023-08-10
5EveFree2024-09-30
6FrankPro2023-12-01

Expected output

Bob|Free|2024-02-20
Carol|Pro|2024-06-01
Eve|Free|2024-09-30

In SQLite, strftime('%Y', date_column) extracts the 4-digit year as a string.

Sample tests

Test #13 of 6 subscriptions are from 2024
Input: "CREATE TABLE subscriptions (id INTEGER, user_name TEXT, plan TEXT, start_date TEXT);\nINSERT INTO subscriptions VALUES\n (1, 'Alice', 'Pro', '2023-11-15'),\n (2, 'Bob', 'Free', '2024-02-20'),\n (3, 'Carol', 'Pro', '2024-06-01'),\n (4, 'Dave', 'Teams', '2023-08-10'),\n (5, 'Eve', 'Free', '2024-09-30'),\n (6, 'Frank', 'Pro', '2023-12-01');"
Output: "Bob|Free|2024-02-20\nCarol|Pro|2024-06-01\nEve|Free|2024-09-30"