Questions tagged [subquery]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
27 views

Query running in developer console but not through Force client in .Net

Following query runs fine in developer console and workbench but fails in .Net code which uses Force Rest client: Select Id, Name, (select contact.id, contact.firstname FROM account.contacts), (...
0
votes
2answers
37 views

Using Multiple SOQL Subqueries

I am currently in the process of bulkifying some trigger code. On a high level, I receive a list of Contact objects, then I need to find the Account associated with it, and count the number of primary ...
0
votes
1answer
28 views

Custom metadata types - subquery relationship name

Is it possible to use Custom Metadata Types in the subqueries? If yes, how? In my case, there is a custom metadata type named Custom Actions and there is a Next_Action field in it. When I query for ...
1
vote
1answer
26 views

Subquery in WHERE clause with multiple fields

I wonder if SOQL ever support multiple fields in WHERE subquery... Something like this (hope, it's self-explanatory): select whatever from Table1 where (Field1, Field2) in (select Field3, Field4 from ...
0
votes
0answers
79 views

Need SOQL help with subquery

I need a query on Accounts and it's related active Instance where an Entitlement of that Account for a specific product is active. Instances and Entitlement do not have a relationship on their own. ...
1
vote
1answer
46 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
134 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 ...
1
vote
2answers
49 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
73 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
14 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
115 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
130 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
766 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
435 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
103 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
2k 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
655 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
2k 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
95 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
25 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
394 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 ...