Skip to content

5. Paid Orders in March

Difficulty: Easy · Topics: Filtering & Selection

orders has order_id, status, order_date ('YYYY-MM-DD') and amount.

Return every order placed in March 2025 (the 1st and the 31st included) whose status is 'PAID' or 'SHIPPED'. Return all columns. Orders with a null status are not included.

Row order does not matter; column names must match. Your code is graded on 3 test cases, including hidden edge cases.

Sample data

orders

order_idstatusorder_dateamount
1PAID2025-03-05250
2CANCELLED2025-03-0790
3SHIPPED2025-03-20400
4PAID2025-04-02120
5PAID2025-02-2860

Expected output

order_idstatusorder_dateamount
1PAID2025-03-05250
3SHIPPED2025-03-20400

Hints

Hint 1Combine conditions with &, each wrapped in parentheses.
Hint 2F.col("order_date").between("2025-03-01", "2025-03-31") includes both ends; ISO date strings compare correctly.
Hint 3F.col("status").isin("PAID", "SHIPPED") is null for a null status, so those rows drop out.

Learn the concepts

PySpark functions you'll practise

Related problems

Browse

Topics: Window Functions · Joins · Aggregations · Pivot, Unpivot & Rollup · Arrays · Null Handling · Conditional Logic · Dates · Filtering & Selection · Strings

Difficulty: Easy · Medium · Hard · PySpark interview roadmap · Learn · All problems