简体   繁体   中英

Blank results when querying the right 4 of a column

New to cross joins and having an issue with one that I'm working on. I'm hoping someone can help both with the query and explain why things are and are not working.

This query gives me results however I'm looking to get the last four of the CompanyAgreement__c.URL__c column for each row.

SELECT Company_Agreement__c.RecordId,
       CompanyAgreement__c.URL__c, 
FROM `Company`.Company_Agreement__c 
WHERE (URL__c != NULL) 
LIMIT 10;

When I add the selection to get the Right most four digits, I get nothing but blank results. The query executes but the result set is empty.

SELECT Company_Agreement__c.RecordId,
       CompanyAgreement__c.URL__c, 
       RIGHT(Company_Agreement__c.URL__c, 4) as LastFour
FROM `Company`.Company_Agreement__c 
WHERE (URL__c != NULL) 
LIMIT 10;

Any ideas how to fix this and what is happening? If it helps, I am working with data coming from Jira and Salesforce which I know uses SOQL. Thanks in advance and please forgive any ignorance in this post.

My expected result set would look something like this.

RecordID    URL__c                     LastFour
1           http://www.testlink-1234    1234
2           http://www.testlink-0525    0525
3           http://www.testlink-3515    3515
4           http://www.testlink-0658    0658
5           http://www.testlink-6812    6812

LEFT and RIGHT functions are not available in SOQL. You will need to create a formula field that returns the last 4 chars then query that formula field.

See this link for ref on how to create a formula for LEFT and RIGHT :

https://help.salesforce.com/articleView?id=000221210&type=1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM