Cash Donations and 80G Eligibility

Easy
80.

Cash Donations and 80G Eligibility

An NGO issues 80G tax receipts for the financial year 2024-25 (1 April 2024 to 31 March 2025, both included). Under the rule it follows, a donation paid in cash above ₹2,000 cannot get an 80G receipt; every other donation can (a cash gift of exactly ₹2,000 still qualifies).

For every donation made in FY 2024-25 return donation_id, donor_name, amount and eligible_80g ('Yes' or 'No'), ordered by donation_id.

Tables

Table: donations

ColumnTypeValues
donation_idint
donor_namevarchar
amountint
payment_modeenumcash, upi, cheque, netbanking
donated_ondate

Primary key: donation_id.

One row per gift; amount is in rupees.

Example

The rows must come back in the order shown.

donations

donation_iddonor_nameamountpayment_modedonated_on
1Saanvi Shah5000upi2024-04-01
2Rohan Gupta2500cash2024-06-15
3Aditi Rao2000cash2024-08-02
4Karan Singh10000cheque2024-03-31
5Meera Nair1500cash2025-01-26
6Liam Das7500netbanking2025-03-31
7Riya Joshi3000cash2025-04-01

Output

donation_iddonor_nameamounteligible_80g
1Saanvi Shah5000Yes
2Rohan Gupta2500No
3Aditi Rao2000Yes
5Meera Nair1500Yes
6Liam Das7500Yes
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.

Cash Donations and 80G Eligibility — SQL Problem

An NGO issues 80G tax receipts for the financial year 2024-25 (1 April 2024 to 31 March 2025, both included).

  • Difficulty: Easy
  • Topics: Conditional Logic, Basics
  • Dialect: MySQL
  • Problem: #80

Problem statement

An NGO issues 80G tax receipts for the financial year 2024-25 (1 April 2024 to 31 March 2025, both included). Under the rule it follows, a donation paid in cash above ₹2,000 cannot get an 80G receipt; every other donation can (a cash gift of exactly ₹2,000 still qualifies).

For every donation made in FY 2024-25 return donation_id, donor_name, amount and eligible_80g ('Yes' or 'No'), ordered by donation_id.

Tables

Table: donations

ColumnType
donation_idint
donor_namevarchar
amountint
payment_modeenum(cash, upi, cheque, netbanking)
donated_ondate

Primary key: donation_id.

One row per gift; amount is in rupees.

Examples

Example 1

donations

donation_iddonor_nameamountpayment_modedonated_on
1Saanvi Shah5000upi2024-04-01
2Rohan Gupta2500cash2024-06-15
3Aditi Rao2000cash2024-08-02
4Karan Singh10000cheque2024-03-31
5Meera Nair1500cash2025-01-26
6Liam Das7500netbanking2025-03-31
7Riya Joshi3000cash2025-04-01

Output

donation_iddonor_nameamounteligible_80g
1Saanvi Shah5000Yes
2Rohan Gupta2500No
3Aditi Rao2000Yes
5Meera Nair1500Yes
6Liam Das7500Yes

How to solve Cash Donations and 80G Eligibility

Indian financial years run April to March, so FY 2024-25 is the closed range from 2024-04-01 to 2025-03-31; the example deliberately has gifts on 31 March 2024 and 1 April 2025 just outside it. BETWEEN or a pair of >=/<= comparisons both work because the dates are stored in sortable YYYY-MM-DD form.

The label is one CASE. Ineligibility needs both conditions together, payment_mode = 'cash' AND amount > 2000; the comparison is strict, so the ₹2,000 cash gift still gets 'Yes'. The IF alternative writes the negation instead — by De Morgan's law, "not (cash and above 2,000)" is "not cash, or at most 2,000" — and returns the same labels.

Every row is read once and nothing is grouped, so the cost is a single scan, or an index range scan on donated_on.

Reference solution (MySQL)

SELECT donation_id, donor_name, amount,
       CASE WHEN payment_mode = 'cash' AND amount > 2000 THEN 'No' ELSE 'Yes' END AS eligible_80g
FROM donations
WHERE donated_on >= '2024-04-01' AND donated_on <= '2025-03-31'
ORDER BY donation_id

Another way

SELECT donation_id, donor_name, amount, IF(payment_mode <> 'cash' OR amount <= 2000, 'Yes', 'No') AS eligible_80g FROM donations WHERE donated_on BETWEEN '2024-04-01' AND '2025-03-31' ORDER BY donation_id

← Library Cards Expiring in March 2025 · Library Members Blocked for Unpaid Fines →