Results 1 to 3 of 3

Thread: Reports Using OR

  1. #1
    tparson is offline Sugar Community Member
    Join Date
    Sep 2006
    Location
    Nova Scotia
    Posts
    67

    Default Reports Using OR

    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!
    Tracy
    CEO
    Saasy Online Services Inc.
    info@saasyonline.com

    647-728-0641
    www.saasyinc.com
    SugarCRM Partner

  2. #2
    tparson is offline Sugar Community Member
    Join Date
    Sep 2006
    Location
    Nova Scotia
    Posts
    67

    Default Re: Reports Using OR

    Further info:

    I note that the query is in blob format in the database and when accessed is not particularly readable. Is this query stored elsewhere where it might be changed?
    Tracy
    CEO
    Saasy Online Services Inc.
    info@saasyonline.com

    647-728-0641
    www.saasyinc.com
    SugarCRM Partner

  3. #3
    Rovion is offline Junior Member
    Join Date
    Jul 2008
    Posts
    1

    Default Re: Reports Using OR

    Quote Originally Posted by tparson
    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.
    In general terms, boolean logic works exactly the opposite of grammatical speech. And is used to add to a set in 'English' and Or is used to exclude "You may have this OR that" vrs boolean or is to include "Where filter is this OR that' generally makes the result set larger for each OR condition met.


    For example gramatically the phrase "I like cars that are convertibles AND luxury cars" would mean that you like convertibles and you also luxury cars.
    To state the same thing in boolean logic Select all cars where type = luxury OR type = convertible.
    Either case would return both sets of all cars in each category. Think of two overlapping circles, one for luxury cars, one for convertibles. In these examples, all cars in both circles would be returned.

    To only get the cars that appear on BOTH circles (luxury cars which are also convertible)
    In Boolean: Select all cars where type = luxury AND type = convertible.

    more info at http://en.wikipedia.org/wiki/Boolean_logic

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Outputting to reports
    By matthewseymour in forum Help
    Replies: 1
    Last Post: 2006-08-20, 08:26 PM
  2. help - Reports have gone missing
    By crmireland in forum Help
    Replies: 0
    Last Post: 2006-07-18, 10:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •