Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- account_code AS customer_account_code,
- branches.name AS customer_branch,
- operating_regions.name AS customer_branch_area,
- notes.created_at AS customer_note_created_at,
- users.name AS customer_note_created_by_name,
- users.job_title AS customer_note_created_by_job_title
- FROM
- customers
- JOIN
- branches ON branch_id = branches.id
- JOIN
- operating_regions ON operating_region_id = operating_regions.id
- LEFT JOIN
- notes ON link_type = 'customer'
- AND customers.id = link_id
- AND DATE(notes.created_at) = '2019-10-11'
- LEFT JOIN
- users ON notes.created_by = users.id
- /*
- WHERE
- the customer had a recent spend cat of A, B, C or D at 2019-10-11 00:00:00
- */
- ORDER BY account_code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement