• Jeff McKinnis 4
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Asking for assistance on query syntax to return a single list of values from 3 fields.  These fields all use the same picklist values.  End goal would be to query and retrive all the non-blank values, combine into a single list and sum the # of records associated with the values.  The query below works, but does not combine into a single list.

SELECT Category_for_Added_Query_1__c,Category_for_Added_Query_2__c,Category_for_Added_Query_3__c, 
SUM(of_Records__c) Total
FROM Audit_Record__c 
WHERE Audit_Formal_Name__c = 'audit name' 
AND 
(Category_for_Added_Query_1__c != null 
OR Category_for_Added_Query_2__c != null 
OR Category_for_Added_Query_3__c != null)
GROUP BY Category_for_Added_Query_1__c,Category_for_Added_Query_2__c,Category_for_Added_Query_3__c

Sample Results:
Sample results
I need help with joined query syntax.

If Resource (pse__Resource__c) has logged billable hours on client projects (pse__Project__r.Account_18_Char_ID__c) within the last 12 months,
return the number of continuing education hours logged during the last 12 months for each resource.

Source Object: 
pse__Timecard__c

Data Fields Needed: 
Resource: pse__Resource__c, pse__Resource__r.FirstName, pse__Resource__r.LastName

Total Hours: pse__Total_Hours__c

Client Project Filter Criteria:
Billable: pse__Billable__c = true
End Date: pse__End_Date__c = LAST_N_MONTHS:12

Continuing Education Filter Criteria: (All CE hours are logged to our account '001G000000oviiRIAQ')
Project Account ID: pse__Project__r.Account_18_Char_ID__c = '001G000000oviiRIAQ'
End Date: pse__End_Date__c = LAST_N_MONTHS:12
Milestone Name:  pse__Milestone__r.Name = 'Coding Compliance Review' OR pse__Milestone__r.Name = 'Other Continuing Education' OR pse__Milestone__r.Name = 'Meetings'


I currently have 2 different queries that work individually.

(Query - 1) This query is currently working to pull CE Hours in last 12 Months:

SELECT  pse__Resource__c, pse__Project__r.Account_18_Char_ID__c, pse__Total_Hours__c, pse__End_Date__c, pse__Milestone__r.Name, pse__Resource__r.FirstName, pse__Resource__r.LastName 
FROM pse__Timecard__c
WHERE pse__Project__r.Account_18_Char_ID__c = '001G000000oviiRIAQ' AND pse__End_Date__c = LAST_N_MONTHS:12 AND  (pse__Milestone__r.Name = 'Coding Compliance Review' OR pse__Milestone__r.Name = 'Other Continuing Education' OR pse__Milestone__r.Name = 'Meetings')

(Query - 2) This query is currently working to pull Resources who whave logged billable hours against a particular client project(s) in the last 12 months:

SELECT  pse__Resource__c, pse__Project__r.Account_18_Char_ID__c, pse__Total_Hours__c, pse__End_Date__c
FROM pse__Timecard__c
WHERE pse__Project__r.Account_18_Char_ID__c = '001G000001laKqrIAE' AND pse__End_Date__c = LAST_N_MONTHS:12 AND pse__Billable__c = true

Again, I am looking for the number of CE hours for any resource who has logged time to a given client's projects by limiting the results of Query 1 by the matching results of Query 2 (matching on pse__Resource__c).
I need help with joined query syntax.

If Resource (pse__Resource__c) has logged billable hours on client projects (pse__Project__r.Account_18_Char_ID__c) within the last 12 months,
return the number of continuing education hours logged during the last 12 months for each resource.

Source Object: 
pse__Timecard__c

Data Fields Needed: 
Resource: pse__Resource__c, pse__Resource__r.FirstName, pse__Resource__r.LastName

Total Hours: pse__Total_Hours__c

Client Project Filter Criteria:
Billable: pse__Billable__c = true
End Date: pse__End_Date__c = LAST_N_MONTHS:12

Continuing Education Filter Criteria: (All CE hours are logged to our account '001G000000oviiRIAQ')
Project Account ID: pse__Project__r.Account_18_Char_ID__c = '001G000000oviiRIAQ'
End Date: pse__End_Date__c = LAST_N_MONTHS:12
Milestone Name:  pse__Milestone__r.Name = 'Coding Compliance Review' OR pse__Milestone__r.Name = 'Other Continuing Education' OR pse__Milestone__r.Name = 'Meetings'


I currently have 2 different queries that work individually.

(Query - 1) This query is currently working to pull CE Hours in last 12 Months:

SELECT  pse__Resource__c, pse__Project__r.Account_18_Char_ID__c, pse__Total_Hours__c, pse__End_Date__c, pse__Milestone__r.Name, pse__Resource__r.FirstName, pse__Resource__r.LastName 
FROM pse__Timecard__c
WHERE pse__Project__r.Account_18_Char_ID__c = '001G000000oviiRIAQ' AND pse__End_Date__c = LAST_N_MONTHS:12 AND  (pse__Milestone__r.Name = 'Coding Compliance Review' OR pse__Milestone__r.Name = 'Other Continuing Education' OR pse__Milestone__r.Name = 'Meetings')

(Query - 2) This query is currently working to pull Resources who whave logged billable hours against a particular client project(s) in the last 12 months:

SELECT  pse__Resource__c, pse__Project__r.Account_18_Char_ID__c, pse__Total_Hours__c, pse__End_Date__c
FROM pse__Timecard__c
WHERE pse__Project__r.Account_18_Char_ID__c = '001G000001laKqrIAE' AND pse__End_Date__c = LAST_N_MONTHS:12 AND pse__Billable__c = true

Again, I am looking for the number of CE hours for any resource who has logged time to a given client's projects by limiting the results of Query 1 by the matching results of Query 2 (matching on pse__Resource__c).