Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two queries that work separately but I cant find a way to combine the two.

Select company, convertedaccount.CreatedDate, CreatedDate From lead Where convertedaccountid In (select id from account) 

Select CreatedDate From AccountHistory Where Field = 'Funded__c'

The idea is to return lead created date, account created date, company name, and date when custom field Funded(that is in account) was modified.

share|improve this question

You can't do this in SOQL.

SOQL (still!) does not support SQL-style arbitrary join queries.

Sub-queries in SOQL are limited to relationship queries (documentation here). Because you want data from the Lead table and the AccountHistory table, which have no native relationship, you cannot get both of them in one SOQL query.

You would need to do this either via Apex code (where you would take the two queries and combine their results using Apex), or by exporting the data and using a SQL database like Access/SQL Server/Oracle etc to query it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.