Once the tables exist, most billing questions are joins. This query finds what a customer is subscribed to and at what price:
select c.email, pr.name as product, p.unit_amount, si.quantity
from customers c
join subscriptions s on s.customer_id = c.id
join subscription_items si on si.subscription_id = s.id
join prices p on p.id = si.price_id
join products pr on pr.id = p.product_id
where s.status = 'active';
This one lists unpaid invoices with their latest payment attempt:
select i.id, i.amount_due, pi.status as payment_status
from invoices i
left join payment_intents pi on pi.invoice_id = i.id
where i.status != 'paid';
The join path is the model: customer to subscription, subscription to items, items to prices, prices to products. Invoices and payment intents hang off the customer and subscription rather than replacing them.