Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.77 KB | None | 0 0
  1. SELECT
  2.     account_code AS customer_account_code,
  3.     branches.name AS customer_branch,
  4.     operating_regions.name AS customer_branch_area,
  5.     notes.created_at AS customer_note_created_at,
  6.     users.name AS customer_note_created_by_name,
  7.     users.job_title AS customer_note_created_by_job_title
  8. FROM
  9.     customers
  10.         JOIN
  11.     branches ON branch_id = branches.id
  12.         JOIN
  13.     operating_regions ON operating_region_id = operating_regions.id
  14.         LEFT JOIN
  15.     notes ON link_type = 'customer'
  16.         AND customers.id = link_id
  17.         AND DATE(notes.created_at) = '2019-10-11'
  18.         LEFT JOIN
  19.     users ON notes.created_by = users.id
  20. /*
  21. WHERE
  22.     the customer had a recent spend cat of A, B, C or D at 2019-10-11 00:00:00
  23. */
  24. ORDER BY account_code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement