Skip to main content

Basic Giving Queries

Start here to learn the fundamentals of querying your church’s giving data. Each example builds on the previous one, helping you gain confidence with SQL.

Query Customization Required

These example queries demonstrate common patterns but may require adjustments to match your specific database schema and field names. Test thoroughly in your environment before use.

Query Requirements

Schema Prefix

IMPORTANT: All tables in the Planning Center Giving module live in the planning_center schema. Always prefix table names with planning_center. in your queries. ✅ CORRECT: SELECT * FROM planning_center.giving_donations ❌ INCORRECT: SELECT * FROM giving_donations

Row Level Security (RLS)

Row Level Security automatically scopes results by:
  • tenant_organization_id – only your organization’s data
  • system_status – only active records by default
Do not add these filters yourself—RLS already enforces them and redundant predicates can slow queries or hide data you expect to see:
  • WHERE tenant_organization_id = 1
  • WHERE system_status = 'active'
Focus on donation-specific filters (date ranges, refunded status, funds) while trusting RLS to handle tenancy and system status.

Table of Contents

Viewing Recent Donations

See Your Latest Donations

Filter by Donation Amount

Finding Donors

List All Active Donors

Search for a Specific Donor

Connect Donations to Donors

This query shows how to link donations with donor information using the relationship table:

Working with Funds

List All Available Funds

See How Donations Are Designated

Connect Donations to Their Fund Designations

Date-Based Queries

Donations This Month

Donations by Week

Year-to-Date Giving

Payment Methods

Breakdown by Payment Method

Online vs Check Giving

Basic Aggregations

Daily Giving Summary

Top Donors This Month (Anonymous)

Fund Performance Summary

Tips for Writing Queries

1. Always Convert Cents to Dollars

2. Filter Out Refunded Donations

3. Use received_at for Timing

  • received_at = When the donation was actually received
  • created_at = When it was entered into the system
  • completed_at = When the transaction completed (may be NULL)

4. Handle NULL Values

5. Case-Insensitive Searches

Next Steps

Ready for more complex queries? Check out:

Common Issues & Solutions

Issue: No results when joining tables

Solution: Check that you’re using the correct relationship_type in your join conditions.

Issue: Amounts look too large

Solution: Remember to divide cents by 100.0 to get dollars.

Issue: Missing recent donations

Solution: Check your WHERE clause - you might be filtering by created_at instead of received_at.

Issue: Duplicate results

Solution: You might be missing a DISTINCT or GROUP BY clause, or joining incorrectly through relationship tables.