TransWikia.com

Using a literal string in SELECT statement

Salesforce Asked by SSK on August 27, 2020

Is there an equivalent SOQL syntax to write following SQL?

SELECT Id, 'Northwind Category' AS Note
FROM categories

2 Answers

Unfortunately, we can't provide a literal string. SOQL only accepts fields and a few select formulas in the fields section of a query. This includes aggregate functions (COUNT, MAX, MIN), toLabel, and TYPEOF (in some cases). If you wanted to include a literal value, you'd have to make a formula and select it as a field.

Correct answer by sfdcfox on August 27, 2020

You can use the Case function to get around this. This is not the standard use - but if you really need it then you can do something like this:

SELECT Id,
CASE
    WHEN ID IS NOT NULL THEN 'Northwind Category'
    ELSE 'Northwind Category'
END AS Note
FROM categories

Alternatively when creating a data extension set a default value.

Answered by Peter Serafin on August 27, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP