I'm wondering if someone could do a comprehensive explanation of how to get reports in Sugar PRO using "OR" rather than "AND" or "ANY". If there is, in fact, an explanation for this it would be a great wiki item.
Specifically: a contact report with related orgs where the field "contact category" (custom) is this
AND
Where the org field X = a specific item from a dropdown
OR
Where the org field Y = a specific item from a dropdown
Query show below that I would like to see
SELECT contacts.id primaryid
,CONCAT(CONCAT(IFNULL(contacts.first_name,''),' '),contacts.last_name) contacts_full_name
FROM contacts
INNER JOIN accounts_contacts l0_l ON contacts.id=l0_l.contact_id AND l0_l.deleted=0
INNER JOIN accounts l0 ON l0.id=l0_l.account_id AND l0.deleted=0
LEFT JOIN contacts_cstm contacts_contacts ON contacts.id = contacts_contacts.id_c
LEFT JOIN accounts_cstm accounts_l0 ON l0.id = accounts_l0.id_c
WHERE (contacts_contacts.category_c like '%SeniorAdministrator%'
AND accounts_l0.x_c IN ('itemA')
)
AND contacts.deleted=0
OR accounts_l0.Y_c IN ('itemC')
)
AND contacts.deleted=0
Thanks!


LinkBack URL
About LinkBacks



Reply With Quote
Bookmarks