Joining Tables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mark Braithwaite
    New Member
    • Oct 2007
    • 22

    Joining Tables

    Hi

    We are trying to edit the SQL query in a dynamic excel spreadsheet which we extracted from CRM. We pull information for different entities and we need to join the tables. We have written the following script and we received an error stating 'Incorrect Column Expression:'Quo te.'.

    SELECT quote.createdon ,
    quote.customeri dname,
    quote. customerid,
    account.address 1_line3,
    account.primary contactid,
    contact.mobilep hone,
    quoteproduct.pr oductid,
    quoteproduct.ne w_productdetail ,
    quoteproduct.qu antity,
    opportunity.est imatedclosedate ,
    opportunity.clo seprobability,
    quoteproduct.ne w_costprice,
    quoteproduct.pr iceperunit,
    quote.new_quote referencenumber
    FROM OpportunityBase WITH (NOLOCK),
    AccountBase WITH (NOLOCK)
    LEFT OUTER JOIN ContactBase WITH (NOLOCK)
    ON AccountBase.Pri maryContactId and
    ContactBase.Del etionStateCode = 0
    LEFT OUTER JOIN CustomerAddress Base WITH (NOLOCK)
    ON CustomerAddress Base.ParentId =
    AccountBase.Acc ountId
    and CustomerAddress Base.AddressNum ber = 1,
    QuoteBase WITH (NOLOCK)
    ON QuoteBase.Quote Id =
    QuoteDetailBase .QuoteId
    and QuoteDetailBase .DeletionStateC ode = 0
    WHERE OpportunityBase .OpportunityId = QuoteBase.Oppor tunityId
    and QuoteBase.Delet ionStateCode = 0
    and OpportunityBase .DeletionStateC ode = 0
    and AccountBase.Acc ountId =OpportunityBas e.AccountId
    and AccountBase.Del etionStateCode = 0

    We would really appreciate any assistance.

    Thanks
Working...