members.invited_by_member_id represents a referral relationship between members.
SQL Question 1 — Total Sales per Member
The first task was to calculate the total sales amount associated with each member. For every member appearing in the transaction records, calculate the sum of payment_amount across that member's purchases. The expected result included the member identifier and aggregated sales amount.
Interviewer Follow-Up
I initially started writing a query using an INNER JOIN. The interviewer then asked whether the query could be simplified and whether the join was necessary at all. This question was relatively straightforward compared with the remaining SQL problems.
SQL Question 2 — Author Statistics and Sales Activity
The second question required calculating three statistics about authors.
Part 1 — Count Unique Authors
Determine the total number of distinct authors in the database.
Part 2 — Percentage of Authors with .com Websites
Calculate the percentage of authors whose website_url contains .com. The metric should be expressed relative to the total number of authors.
Part 3 — Percentage of Authors Who Have Never Sold a Book
Calculate the percentage of authors who have no recorded book sales. This required connecting authors to their published books and the corresponding transaction records.
Implementation Discussion
I worked with an intermediate aggregation of sales by author and then connected the result to the author table. The tricky part was handling authors without matching transaction records correctly. The question required combining author-level statistics with sales activity while preserving authors who had never generated any sales.
SQL Question 3 — Average Payment per Book and Member Referrals
The third SQL question involved calculating average payment per book while incorporating referral relationships between members. The relevant tables were transactions and members. The payment calculation was based on transaction amounts and quantities, while
Unlock Full Details
Create a free account to unlock this interview experience report.