A project has 3 tables : client, invoices, deliveries
The relations are:
client has_many invoices
client has_many deliveries
invoices belongs_to client
deliveries belongs_to client
Both invoices and deliveries model have a date field.
Now I want to find all clients who has at least 1 record either in invoices or deliveries within that month, so that need the distinct clients who have records in invoices or have records in deliveries or even both.
How to find the clients using Rails or even SQL ?
Thanks for help