SQL for Fundraisers
Hello and welcome! This site is a free resource offered to the nonprofit fundraising community. My aim is to teach you to write SQL (or write better SQL) using hands-on, industry-specific examples.
About me
I'm Adam Rosenscruggs, founder of Gambit Analytics. I have been working in the nonprofit fundraising industry since 2007 and have worked on the organization side as well as on the consulting side. I began my career in the membership department of the Human Rights Campaign before transitioning to database and analytics roles.
I want to highlight that I am self-taught in SQL, not because it's an awesome brag but because I want to emphasize that I didn't study this in college, did not have any database experience before starting my first job, and wrote my first line of SQL as the sustainer program intern at HRC.
You do not need a background in information systems or computer science to teach yourself SQL (though those things are helpful). All you need is a desire to learn and a practical way to gain experience. If you provide the former, I am hoping this site will provide the latter.
What you will learn here
I will walk you through everything you need to know to query data from a database using the SQL select
statement. Right now, this concept may seem a bit abstract to you. Here's what I mean in more concrete terms. When you are done with this course, you will be able to:
- Get specific data out of a database (e.g., donor ID, date of last gift, donor name) using SQL.
- Use
joins
to combine data from multiple tables in a database. - Use
where
clauses to filter and limit the data you're extracting to meet specific business requirements (e.g., "Donors who live in the state of Michigan", "Donors with highest lifetime gift of $50+ with at least one gift in the last 6 months".) - Use common table expressions (CTEs) and subqueries to build and join your own complex tables from underlying data.
- Use aggregate functions like
sum()
andcount()
to summarize data in a database (e.g., "Total revenue by source code", "Count of donors by state of residence".) - Use window functions like
lead()
androw_number()
(aka analytical functions) to retrieve data with complex relationships (e.g., "Generate a list of each donor's most recent contribution amount as well as the amount of their immediately preceding gift".)
How to use this site
Each page provides written instruction alongside interactive SQL query windows that allow you to write code and see results right on the page where the instruction is displayed. The navigation on the left side of the page is organized in chapters from top to bottom such that the content builds on itself. I recommend starting with Chapter 0 - What is a database?.
If you already have some familiarity with SQL, you will likely breeze through the initial chapters. But I recommend you start there anyway, as there may be some concepts where a refresher would be helpful.
Updates
I am planning to release several updates to this course in the coming months, including:
- A large set of additional practical exercises and their solutions
- Additional instruction on window functions
- Additional instruction on windowed aggregates
- Dialect-specific function listings
If you'd like to be notified when updates are released, sign up here. I won't share your information with anyone, I will only use it to let you know when updates have been released.