Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [subquery]

The tag has no usage guidance.

1
vote
1answer
39 views

Sub query result is 0

I want to get the Opportunity Ids of the Opportunity records that have associated OpportunityLineItems but no Revenue_Pipeline__c custom object records for a batch class. I have my sub-query which ...
0
votes
1answer
41 views

Extending WHERE clause with condition from another query

I have two different queries which give the results, however is there a way to combine 2 queries and extend the WHERE clause as below: Query 1 SELECT Id, Name, (Select ID, Name, Object_C__r.Name ...
0
votes
2answers
25 views

Combine and Query 2 Child object to a Parent Object

I was wondering can you combine 2 child objects to a parent object. SELECT SourceIp FROM LoginHistory WHERE UserId IN (SELECT Id FROM User) SELECT City FROM LoginGeo WHERE CreatedbyId (SELECT Id ...
0
votes
2answers
59 views

Rewrite query to make it without subqueries

I have some custom objects displayed on schema. I need return vacancies which have last active interview at least week ago. I have some query: List<Vacancy__c> ids = new List<Vacancy__c>(...
-1
votes
1answer
13 views

The system saves the records that fired the before trigger after the trigger finishes execution? [closed]

trigger HelloWorldTrigger on Account (before insert) { for(Account a : Trigger.New) { a.Description = 'New description'; } } Copy
1
vote
1answer
61 views

Flatten SOQL Subquery to return 1 row per ActivityHistory

I currently have this query: SELECT (SELECT CallDurationInSeconds, CallData__c, Closed_After_DueDate__c, Reminder_Date_Time_LEX__c, PrimaryWhoId, Current_User_Assigned__c, LastModifiedById, ...
3
votes
1answer
74 views

Querying Opportunities related to a contact return only Open Opportunities

I am doing subquery Of Opportunities on Contact as follows:- Select id,(select id from Opportunities) from Contact where id in (select ContactId from OpportunityContactRole) I know this will return ...
1
vote
1answer
317 views

How to iterate sub query on lightning page

I want to display the contact names and opportunity names where AccountID is not null, I am able to display the contact names, can someone please help me to display the opportunity names too? Below ...
3
votes
2answers
261 views

Left outer join safety in SOQL

I covered this post. There I met the following query: SELECT Name, (SELECT Name FROM Job_Applications__r) FROM Position__c Here is the explanation provided in the post: Note that we have utilized ...
0
votes
1answer
68 views

parent-child relationship subqueries not contributing to governor limits

As per the article Execution Governors and Limits In a SOQL query with parent-child relationship subqueries, each parent-child relationship counts as an extra query. The row counts from these ...
0
votes
1answer
485 views

Query for parent-to-child (lookup) [duplicate]

I need to query all the related children of an object, the connection is via a lookup relationship. Query as follows to illustrate: SELECT (SELECT Id FROM Orders) FROM Invoice__c Error message: ...
0
votes
1answer
261 views

How to loop trough subquery relations [MAP] and put all in 1 [MAP] [closed]

I have a before insert trigger where Relatietype__c is a junction object on contact and account. I need to compare these with a 3rd object Huishouden__c with the Huishouden__c.name field which is a ...
3
votes
1answer
1k views

Dynamic SOQL, Access Subquery Results

I'm having trouble understanding how to access each individual result returned from a subquery. The picture shows the code which: takes fields and objects chosen by a user and assigns them to String ...
0
votes
1answer
66 views

Why my soql query is returning 'RecordTypeId' instead of the fields mentioned in the query? [duplicate]

Why my soql query is returning 'RecordTypeId' instead of the fields mentioned in the query? Here's my query: SELECT Id, Name, ABC, (SELECT Id, XYZ FROM InnerObject) FROM OuterObj Note: My query ...
0
votes
1answer
22 views

What is the Correct collection class structure to hold SOQL subquery results?

I've got a scenario where a status field on the parent object needs to be updated to reflect the status of the most recently created child object. To solve this, I've done a SOQL with a subquery :- ...
2
votes
1answer
252 views

Cannot use ALL ROWS in a SOQL subquery?

I need to query all Tasks from a Case, and some of the Tasks are over a year old, which makes them invisible to SOQL unless you use the ALL ROWS keyword. I tried to use ALL ROWS in the subquery, but ...