Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-1358

Getting wrong results when using JOINs in a query

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 7.2
    • 7.1
    • Salesforce Connector
    • None

    Description

      I am getting completely wrong results if I am using a JOIN in my SELECT statement:

      select o.Id,
      o.Name,
      o.Amount,
      o.StageName,
      o.ForecastCategory
      from general.salesforce.Opportunity o
      where 1=1
      and o.Fiscal = '2011 3'
      and o.OwnerId = (select Id from general.salesforce.User where Name = '****') --> real name
      ;

      This statement returns 36 lines. I would now like to also get OpportunityLineItem(s) to this Opportunities, so I am adding a join

      select o.Id,
      (select Name from general.salesforce.User where id = o.OwnerId) as OpportunityOwner,
      (select Name from general.salesforce.Account where id = o.AccountId) as AccountName,
      o.Name,
      o.Amount,
      o.StageName,
      o.ForecastCategory
      from general.salesforce.OpportunityLineItem oli
      LEFT INNER general.salesforce.Opportunity o ON oli.OpportunityId = o.id
      where 1=1
      and o.Fiscal = '2011 3'
      and o.OwnerId = (select Id from general.salesforce.User where Name = '****') --> same name as above
      ;

      Now I do not get any results back.

      However, one may think that there is no OpportunityLineItem for those Opportunities above. But if I am querying just OpportunityLineItems of one Opp above, I do get many of them:

      select * from general.salesforce.OpportunityLineItem oli where OpportunityId = '0066000000DoIHaAAN';

      Maybe I am missing something here?

      Thanks for any help.

      Cheers,
      Wanja

      Attachments

        Activity

          People

            rhn-engineering-shawkins Steven Hawkins
            wpernath_jira Wanja Pernath (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: