Fixed Deposits Maturing in March 2025

Easy
52.

Fixed Deposits Maturing in March 2025

EasyDates

MySQL

Relationship managers call customers a month before their fixed deposits mature, to offer a renewal. A deposit matures exactly tenure_months months after its start_date (the same day of the month).

Return fd_id, customer_name and maturity_date for every deposit that matures in March 2025 (1 to 31 March inclusive). Order the rows by maturity_date, then by fd_id.

Tables

Table: FixedDeposit

ColumnType
fd_idint
customer_namevarchar
principalint
rate_pctdecimal
start_datedate
tenure_monthsint

Primary key: fd_id.

One row per fixed deposit. Start dates always fall on day 1–28 of a month.

Example

The rows must come back in the order shown.

FixedDeposit

fd_idcustomer_nameprincipalrate_pctstart_datetenure_months
1Meera Iyer2000007.12024-03-1512
2Rahul Verma500006.82024-09-016
3Ananya Das5000007.252022-03-2836
4Vikram Singh10000072024-04-0112
5Zara Khan750006.52024-12-103
6Harsh Patel3000007.12023-02-2024

Output

fd_idcustomer_namematurity_date
2Rahul Verma2025-03-01
5Zara Khan2025-03-10
1Meera Iyer2025-03-15
3Ananya Das2025-03-28
Read the hints, the editorial and the reference solution
-- Write your MySQL query below

Sign in to write, run and submit queries

A free account — no card, no trial clock. You come straight back here.

Run your query to see its result next to the expected one, example by example.

Fixed Deposits Maturing in March 2025 — SQL Dates Problem

Relationship managers call customers a month before their fixed deposits mature, to offer a renewal.

  • Difficulty: Easy
  • Topics: Dates
  • Dialect: MySQL
  • Problem: #52

Problem statement

Relationship managers call customers a month before their fixed deposits mature, to offer a renewal. A deposit matures exactly tenure_months months after its start_date (the same day of the month).

Return fd_id, customer_name and maturity_date for every deposit that matures in March 2025 (1 to 31 March inclusive). Order the rows by maturity_date, then by fd_id.

Tables

Table: FixedDeposit

ColumnType
fd_idint
customer_namevarchar
principalint
rate_pctdecimal
start_datedate
tenure_monthsint

Primary key: fd_id.

One row per fixed deposit. Start dates always fall on day 1–28 of a month.

Examples

Example 1

FixedDeposit

fd_idcustomer_nameprincipalrate_pctstart_datetenure_months
1Meera Iyer2000007.12024-03-1512
2Rahul Verma500006.82024-09-016
3Ananya Das5000007.252022-03-2836
4Vikram Singh10000072024-04-0112
5Zara Khan750006.52024-12-103
6Harsh Patel3000007.12023-02-2024

Output

fd_idcustomer_namematurity_date
2Rahul Verma2025-03-01
5Zara Khan2025-03-10
1Meera Iyer2025-03-15
3Ananya Das2025-03-28

How to solve Fixed Deposits Maturing in March 2025

The maturity date is derived, not stored: DATE_ADD(start_date, INTERVAL tenure_months MONTH) moves each start date forward by its own tenure, keeping the day of the month (the start dates stop at the 28th, so no month-end clamping is involved). Select it under the name maturity_date and filter on the same expression.

The filter can be a range (BETWEEN '2025-03-01' AND '2025-03-31', inclusive at both ends), a YEAR(...) = 2025 AND MONTH(...) = 3 pair, or DATE_FORMAT(..., '%Y-%m') = '2025-03'. All three are equivalent here. In a real table the range form is preferred when the date is a stored, indexed column — but because this one is computed, every form scans the table.

A column alias cannot be used in the WHERE of the same query (it is evaluated before SELECT), so either repeat the expression or compute it in a derived table and filter outside, as one alternative does. The order is fixed by maturity date with fd_id breaking ties.

Reference solution (MySQL)

SELECT fd_id, customer_name, DATE_ADD(start_date, INTERVAL tenure_months MONTH) AS maturity_date
FROM FixedDeposit
WHERE DATE_ADD(start_date, INTERVAL tenure_months MONTH) BETWEEN '2025-03-01' AND '2025-03-31'
ORDER BY maturity_date, fd_id

Another way

SELECT fd_id, customer_name, maturity_date FROM (
  SELECT fd_id, customer_name, DATE_ADD(start_date, INTERVAL tenure_months MONTH) AS maturity_date FROM FixedDeposit
) t WHERE YEAR(maturity_date) = 2025 AND MONTH(maturity_date) = 3 ORDER BY maturity_date, fd_id

Another way

SELECT fd_id, customer_name, DATE_ADD(start_date, INTERVAL tenure_months MONTH) AS maturity_date FROM FixedDeposit WHERE DATE_FORMAT(DATE_ADD(start_date, INTERVAL tenure_months MONTH), '%Y-%m') = '2025-03' ORDER BY maturity_date, fd_id

← Masked Card Numbers for Card Statements · Loan Applicants by Credit Score Band →