BrewQL syntax question

The BrewQL syntax

order_status = “Invoiced” and customer.name ~ “Papi” and customer.invoices.payment_status = “Unpaid”

Is returning both paid and unpaid invoices in a report. What am I doing wrong?

The customer.invoices.payment_status = “Unpaid” part is where this is going wrong. You’re starting with the invoice table as the base for the query, then going to the customer, then going to all the customer’s invoices (customer.invoices.) and checking if this customer has any unpaid invoices - so isn’t actually filtering the invoice in question. If you remove the customer.invoices. part, it should work:

order_status = “Invoiced” and customer.name ~ “Papi” and payment_status = “Unpaid”

1 Like