Excel Query for Salesforce
Posted: Tue 24 Jan 2017 14:43
HI,
Testing the Excel Add-on for Salesforce and finding it useful. However not an SQL expert and although I can read and make minor edits, have hit a brick wall. Have the query below which brings me, what we call, neglected Opportunities prior to 1st January - in that there is no obvious notes been made on account since that date.
I would like the date to be dynamic in that it is always 30 days prior to 'today' so when report runs it filters anything with modified or updates in last 30 days. COudl anyone advise on the code to use?
SELECT t.Id,
t.Name,
t.StageName,
t.Amount,
t.CloseDate,
t.NextStep,
t.Op_URL__c,
AccountId.Name AS "AccountId.Name",
OwnerId.FirstName AS "OwnerId.FirstName"
FROM Opportunity AS t
LEFT OUTER JOIN Account AS AccountId ON t.AccountId = AccountId.Id
INNER JOIN User AS OwnerId ON t.OwnerId = OwnerId.Id
WHERE ((t.LastActivityDate < '2017-01-01' AND t.LastModifiedDate < '2017-01-01 12:14:47') AND (t.IsClosed != True))
ORDER BY t.CloseDate
Testing the Excel Add-on for Salesforce and finding it useful. However not an SQL expert and although I can read and make minor edits, have hit a brick wall. Have the query below which brings me, what we call, neglected Opportunities prior to 1st January - in that there is no obvious notes been made on account since that date.
I would like the date to be dynamic in that it is always 30 days prior to 'today' so when report runs it filters anything with modified or updates in last 30 days. COudl anyone advise on the code to use?
SELECT t.Id,
t.Name,
t.StageName,
t.Amount,
t.CloseDate,
t.NextStep,
t.Op_URL__c,
AccountId.Name AS "AccountId.Name",
OwnerId.FirstName AS "OwnerId.FirstName"
FROM Opportunity AS t
LEFT OUTER JOIN Account AS AccountId ON t.AccountId = AccountId.Id
INNER JOIN User AS OwnerId ON t.OwnerId = OwnerId.Id
WHERE ((t.LastActivityDate < '2017-01-01' AND t.LastModifiedDate < '2017-01-01 12:14:47') AND (t.IsClosed != True))
ORDER BY t.CloseDate